API
ReactiveTransportโ
ReactiveTransport
is the main entry point to configure a reactive server and client.
tip
You could call the shutdown
method if you want to close all connections and stop all transports (reactive and IOUring)
Declaration
class ReactiveTransport {
ReactiveTransport(Transport, TransportWorker, ReactiveTransportConfiguration)
Future<void> shutdown({bool transport = false}) async
void serve(
InternetAddress address,
int port,
void Function(ReactiveSubscriber subscriber) acceptor, {
void onError(ReactiveException exception)?,
void onShutdown()?,
TransportTcpServerConfiguration? tcpConfiguration,
ReactiveBrokerConfiguration? brokerConfiguration,
ReactiveLeaseConfiguration? leaseConfiguration,
})
void connect(
InternetAddress address,
int port,
void Function(ReactiveSubscriber subscriber) connector, {
void onError(ReactiveException exception)?,
void onShutdown()?,
TransportTcpClientConfiguration? tcpConfiguration,
ReactiveSetupConfiguration? setupConfiguration,
ReactiveBrokerConfiguration? brokerConfiguration,
})
Example
final transport = Transport();
final worker = TransportWorker(transport.worker(ReactiveTransportDefaults.transport().workerConfiguration));
await worker.initialize();
final reactive = ReactiveTransport(transport, worker, ReactiveTransportDefaults.transport());
reactive.serve(
InternetAddress.anyIPv4,
12345,
(subscriber) {
/* Configure server subscriber */
},
);
reactive.connect(
InternetAddress.loopbackIPv4,
12345,
(subscriber) {
/* Configure client subscriber */
},
);
/* Handle stop on your own */
await reactive.shutdown(transport: true);
Methodsโ
serveโ
Create and configure RSocket server.
connectโ
Create and configure RSocket client.