Problem
Today, ReactiveSocket does not know when the underlying DuplexConnection is closed. This has two problems:
- The underlying connection close is only discovered on writing a
KeepAlive frame or writing/reading other frames. Although this "works" but is not ideal as that means we have to wait till the KeepAlive duration or next write to know about something that is easily available from the transport layer.
- There is currently no way of notifying a user when a
ReactiveSocket closes. onShutdown() only handles explicit shutdown() calls.
Proposal
We can add two methods to ReactiveSocket, viz.,
/**
* Close this {@code ReactiveSocket} upon subscribing to the returned {@code Publisher}
*
* <em>This method is idempotent and hence can be called as many times at any point with same outcome.</em>
*
* @return A {@code Publisher} that completes when this {@code ReactiveSocket} close is complete.
*/
Publisher<Void> close();
and
/**
* Returns a {@code Publisher} that completes when this {@code ReactiveSocket} is closed. A {@code ReactiveSocket}
* can be closed by explicitly calling {@link #close()} or when the underlying transport connection is closed.
*
* @return A {@code Publisher} that completes when this {@code ReactiveSocket} close is complete.
*/
Publisher<Void> closeNotifier();
The above can replace the following methods that currently exist:
void onShutdown(Completable c);
void close() throws Exception;
Same methods will be added to DuplexConnection thus wiring close() together and providing correct notifications to users when the ReactiveSocket is closed.
We can modify onShutdown() and shutdown() methods to the signature of my proposal but I think close() is more inline with other implementations of connections found elsewhere.
Current close() method is inherited from AutoCloseable which signifies synchronous execution as it return void.
Problem
Today,
ReactiveSocketdoes not know when the underlyingDuplexConnectionis closed. This has two problems:KeepAliveframe or writing/reading other frames. Although this "works" but is not ideal as that means we have to wait till theKeepAliveduration or next write to know about something that is easily available from the transport layer.ReactiveSocketcloses.onShutdown()only handles explicitshutdown()calls.Proposal
We can add two methods to
ReactiveSocket, viz.,and
The above can replace the following methods that currently exist:
Same methods will be added to
DuplexConnectionthus wiringclose()together and providing correct notifications to users when theReactiveSocketis closed.We can modify
onShutdown()andshutdown()methods to the signature of my proposal but I thinkclose()is more inline with other implementations of connections found elsewhere.Current
close()method is inherited fromAutoCloseablewhich signifies synchronous execution as it returnvoid.