Skip to content

Conversation

@stevegury
Copy link
Member

@stevegury stevegury commented May 31, 2016

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 ReactiveSocketProxy helper class, which ease the task of wrapping
a ReactiveSocket instance for extending its behavior.

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.
@NiteshKant
Copy link
Contributor

👍 for removing the address argument from the factory, this is similar to what I converged to in RxNetty!

I did not see the connector class though

@stevegury
Copy link
Member Author

@NiteshKant My bad, I added the missing files.

protected final ReactiveSocket child;
private final Function<Subscriber<? super Payload>, Subscriber<? super Payload>> subscriberWrapper;

public ReactiveSocketProxy(ReactiveSocket child, Function<Subscriber<? super Payload>, Subscriber<? super Payload>> subscriberWrapper) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if extension is a better approach here as opposed to a single subscriber wrapper function, which only is applicable to methods that return Publisher<Void>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it's most of the time a cleaner approach.
That been said, this is pretty convenient to be able to do that here.

@NiteshKant
Copy link
Contributor

Apart from the minor comment on ReactiveSocketProxy I think this is good.

@robertroeser robertroeser merged commit dfe6987 into master Jun 7, 2016
@stevegury stevegury deleted the stevegury/availability branch July 15, 2016 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants