Introduce Connector and availability for Connection #85
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The DuplexConnection class doesn't expose any way to probe its state,
this is somewhat problematic and doesn't fit well in the current
model where the availability is the composable way of chaining state.
The ReactiveSocketFactory create a ReactiveSocket from an
address(currently SocketAddress). There are places in the code where the concept
of address is not needed and it leads to implicit dependency on it.
Solution
Add a
double availability()method to the DuplexConnection interface,most implementation of this method will be straightforward (just
returning 0.0 if the underlying resource is unavailable, 1.0 otherwise).
Split the concept of ReactiveSocketFactory in two, the Factory and the
Connector. The Connector is responsible for creating the ReactiveSocket
from the address, and the factory can create a ReactiveSocket without
any argument.
Modification
I added a
ReactiveSocketProxyhelper class, which ease the task of wrappinga ReactiveSocket instance for extending its behavior.