public class NetStreams extends Streams
//echo server
NetStreams.tcpServer(1234).start( connection -> ch.writeWith(connection) );
NetStreams.tcpClient(1234).start( connection ->
connection
//Listen for any incoming data on that connection, they will be Buffer an IOStream can easily decode
.nest()
.flatMap(self -> IOStreams.decode(new StringCodec('\n'), self))
.consume(log::info);
//Push anything from the publisher returned, here a simple Reactor Stream. By default a Buffer is expected
//Will close after write
return connection.writeWith(Streams.just(Buffer.wrap("hello\n")));
);
//We can also preconfigure global codecs and other custom client/server parameter with the Function signature:
NetStreams.tcpServer(spec -> spec.codec(kryoCodec).listen(1235)).start( intput -> {
input.consume(log::info);
return input.writeWith(Streams.period(1l));
});
//Assigning the same codec to a client and a server greatly improve readability and provide for extended type safety.
NetStreams.tcpClient(spec -> spec.connect("localhost", 1235).codec(kryoCodec)).start( input -> {
input.consume(log::info);
return input.writeWith(Streams.just("hello"));
});
}
Modifier and Type | Class and Description |
---|---|
static interface |
NetStreams.HttpClientFactory<IN,OUT> |
static interface |
NetStreams.HttpServerFactory<IN,OUT> |
static interface |
NetStreams.TcpClientFactory<IN,OUT> |
static interface |
NetStreams.TcpServerFactory<IN,OUT> |
static interface |
NetStreams.UdpServerFactory<IN,OUT> |
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_BIND_ADDRESS |
static Class<? extends HttpClient> |
DEFAULT_HTTP_CLIENT_TYPE |
static Class<? extends HttpServer> |
DEFAULT_HTTP_SERVER_TYPE |
static int |
DEFAULT_PORT |
static Class<? extends TcpClient> |
DEFAULT_TCP_CLIENT_TYPE |
static Class<? extends TcpServer> |
DEFAULT_TCP_SERVER_TYPE |
static Class<? extends DatagramServer> |
DEFAULT_UDP_SERVER_TYPE |
Modifier and Type | Method and Description |
---|---|
static Spec.IncrementalBackoffReconnect |
backoffReconnect() |
static <E,IN,OUT> E |
delegate(ChannelStream<IN,OUT> channelStream)
Utils to read the ChannelStream underlying channel
|
static <E,IN,OUT> E |
delegate(ChannelStream<IN,OUT> channelStream,
Class<E> clazz) |
static HttpClient<Buffer,Buffer> |
httpClient() |
static <IN,OUT> HttpClient<IN,OUT> |
httpClient(Class<? extends HttpClient> clientFactory,
Function<? super Spec.HttpClientSpec<IN,OUT>,? extends Spec.HttpClientSpec<IN,OUT>> configuringFunction)
Bind a new HTTP client to the specified connect address and port.
|
static <IN,OUT> HttpClient<IN,OUT> |
httpClient(Function<? super Spec.HttpClientSpec<IN,OUT>,? extends Spec.HttpClientSpec<IN,OUT>> configuringFunction)
Bind a new HTTP client to the specified connect address and port.
|
static HttpServer<Buffer,Buffer> |
httpServer()
Build a simple Netty HTTP server listening on 127.0.0.1 and 12012
|
static <IN,OUT> HttpServer<IN,OUT> |
httpServer(Class<? extends HttpServer> serverFactory,
Function<? super Spec.HttpServerSpec<IN,OUT>,? extends Spec.HttpServerSpec<IN,OUT>> configuringFunction) |
static <IN,OUT> HttpServer<IN,OUT> |
httpServer(Function<? super Spec.HttpServerSpec<IN,OUT>,? extends Spec.HttpServerSpec<IN,OUT>> configuringFunction)
Build a Netty HTTP Server with the passed factory
|
static HttpServer<Buffer,Buffer> |
httpServer(int port)
Build a simple Netty HTTP server listening on 127.0.0.1 and the passed port
|
static HttpServer<Buffer,Buffer> |
httpServer(String bindAddress)
Build a simple Netty HTTP server listening on 127.0.0.1 and 12012
|
static HttpServer<Buffer,Buffer> |
httpServer(String bindAddress,
int port)
Build a simple Netty HTTP server listening othe passed bind address and port
|
static TcpClient<Buffer,Buffer> |
tcpClient()
Bind a new TCP client to the localhost on port 12012.
|
static <IN,OUT> TcpClient<IN,OUT> |
tcpClient(Class<? extends TcpClient> clientFactory,
Function<? super Spec.TcpClientSpec<IN,OUT>,? extends Spec.TcpClientSpec<IN,OUT>> configuringFunction)
Bind a new TCP client to the specified connect address and port.
|
static <IN,OUT> TcpClient<IN,OUT> |
tcpClient(Function<? super Spec.TcpClientSpec<IN,OUT>,? extends Spec.TcpClientSpec<IN,OUT>> configuringFunction)
Bind a new TCP client to the specified connect address and port.
|
static TcpClient<Buffer,Buffer> |
tcpClient(int port)
Bind a new TCP client to "loopback" on the the specified port.
|
static TcpClient<Buffer,Buffer> |
tcpClient(String bindAddress)
Bind a new TCP client to the specified connect address and port 12012.
|
static TcpClient<Buffer,Buffer> |
tcpClient(String bindAddress,
int port)
Bind a new TCP client to the specified connect address and port.
|
static TcpServer<Buffer,Buffer> |
tcpServer()
Bind a new TCP server to "loopback" on port 12012.
|
static <IN,OUT> TcpServer<IN,OUT> |
tcpServer(Class<? extends TcpServer> serverFactory,
Function<? super Spec.TcpServerSpec<IN,OUT>,? extends Spec.TcpServerSpec<IN,OUT>> configuringFunction)
Bind a new TCP server to the specified bind address and port.
|
static <IN,OUT> TcpServer<IN,OUT> |
tcpServer(Function<? super Spec.TcpServerSpec<IN,OUT>,? extends Spec.TcpServerSpec<IN,OUT>> configuringFunction)
Bind a new TCP server to the specified bind address and port.
|
static TcpServer<Buffer,Buffer> |
tcpServer(int port)
Bind a new TCP server to "loopback" on the given port.
|
static TcpServer<Buffer,Buffer> |
tcpServer(String bindAddress)
Bind a new TCP server to the given bind address on port 12012.
|
static TcpServer<Buffer,Buffer> |
tcpServer(String bindAddress,
int port)
Bind a new TCP server to the given bind address and port.
|
static DatagramServer<Buffer,Buffer> |
udpServer()
Bind a new UDP server to the "loopback" address.
|
static <IN,OUT> DatagramServer<IN,OUT> |
udpServer(Class<? extends DatagramServer> serverFactory,
Function<? super Spec.DatagramServerSpec<IN,OUT>,? extends Spec.DatagramServerSpec<IN,OUT>> configuringFunction)
Bind a new UDP server to the specified bind address and port.
|
static <IN,OUT> DatagramServer<IN,OUT> |
udpServer(Function<? super Spec.DatagramServerSpec<IN,OUT>,? extends Spec.DatagramServerSpec<IN,OUT>> configuringFunction)
Bind a new UDP server to the specified bind address and port.
|
static DatagramServer<Buffer,Buffer> |
udpServer(int port)
Bind a new UDP server to the "loopback" address and specified port.
|
static DatagramServer<Buffer,Buffer> |
udpServer(String bindAddress)
Bind a new UDP server to the given bind address.
|
static DatagramServer<Buffer,Buffer> |
udpServer(String bindAddress,
int port)
Bind a new UDP server to the given bind address and port.
|
await, await, await, await, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, concat, concat, concat, concat, concat, concat, concat, concat, concat, create, createWith, createWith, createWith, defer, empty, fail, from, from, from, from, generate, join, join, join, join, join, join, join, join, join, just, just, just, just, just, just, just, just, merge, merge, merge, merge, merge, merge, merge, merge, merge, never, period, period, period, period, period, period, period, period, range, switchOnNext, switchOnNext, switchOnNext, switchOnNext, timer, timer, timer, timer, wrap, zip, zip, zip, zip, zip, zip, zip, zip, zip
public static final int DEFAULT_PORT
public static final String DEFAULT_BIND_ADDRESS
public static final Class<? extends HttpServer> DEFAULT_HTTP_SERVER_TYPE
public static final Class<? extends HttpClient> DEFAULT_HTTP_CLIENT_TYPE
public static final Class<? extends DatagramServer> DEFAULT_UDP_SERVER_TYPE
public static TcpServer<Buffer,Buffer> tcpServer()
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
public static TcpServer<Buffer,Buffer> tcpServer(int port)
A TcpServer
is a specific kind of Publisher
that will emit:
- onNext ChannelStream
to consume data from
- onComplete when server is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
port
- the port to listen on loopbackpublic static TcpServer<Buffer,Buffer> tcpServer(String bindAddress)
A TcpServer
is a specific kind of Publisher
that will emit:
- onNext ChannelStream
to consume data from
- onComplete when server is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
bindAddress
- bind address (e.g. "127.0.0.1") to create the server on the default port 12012public static TcpServer<Buffer,Buffer> tcpServer(String bindAddress, int port)
A TcpServer
is a specific kind of Publisher
that will emit:
- onNext ChannelStream
to consume data from
- onComplete when server is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
port
- the port to listen on the passed bind addressbindAddress
- bind address (e.g. "127.0.0.1") to create the server on the passed portpublic static <IN,OUT> TcpServer<IN,OUT> tcpServer(Function<? super Spec.TcpServerSpec<IN,OUT>,? extends Spec.TcpServerSpec<IN,OUT>> configuringFunction)
A TcpServer
is a specific kind of Publisher
that will emit:
- onNext ChannelStream
to consume data from
- onComplete when server is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
IN
- the given input type received by this peer. Any configured codec decoder must match
this type.OUT
- the given output type received by this peer. Any configured codec encoder must match
this type.configuringFunction
- a function will apply and return a Spec
to customize the peerpublic static <IN,OUT> TcpServer<IN,OUT> tcpServer(Class<? extends TcpServer> serverFactory, Function<? super Spec.TcpServerSpec<IN,OUT>,? extends Spec.TcpServerSpec<IN,OUT>> configuringFunction)
A TcpServer
is a specific kind of Publisher
that will emit:
- onNext ChannelStream
to consume data from
- onComplete when server is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
IN
- the given input type received by this peer. Any configured codec decoder must match
this type.OUT
- the given output type received by this peer. Any configured codec encoder must match
this type.serverFactory
- the given implementation class for this peerconfiguringFunction
- a function will apply and return a Spec
to customize the peerpublic static TcpClient<Buffer,Buffer> tcpClient()
A TcpClient
is a specific kind of Publisher
that will emit:
- onNext ChannelStream
to consume data from
- onComplete when client is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
public static TcpClient<Buffer,Buffer> tcpClient(String bindAddress)
A TcpClient
is a specific kind of Publisher
that will emit:
- onNext ChannelStream
to consume data from
- onComplete when client is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
bindAddress
- the address to connect to on port 12012public static TcpClient<Buffer,Buffer> tcpClient(int port)
A TcpClient
is a specific kind of Publisher
that will emit:
- onNext ChannelStream
to consume data from
- onComplete when client is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
port
- the port to connect to on "loopback"public static TcpClient<Buffer,Buffer> tcpClient(String bindAddress, int port)
A TcpClient
is a specific kind of Publisher
that will emit:
- onNext ChannelStream
to consume data from
- onComplete when client is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
bindAddress
- the address to connect toport
- the port to connect topublic static <IN,OUT> TcpClient<IN,OUT> tcpClient(Function<? super Spec.TcpClientSpec<IN,OUT>,? extends Spec.TcpClientSpec<IN,OUT>> configuringFunction)
A TcpClient
is a specific kind of Publisher
that will emit:
- onNext ChannelStream
to consume data from
- onComplete when client is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
IN
- the given input type received by this peer. Any configured codec decoder must match
this type.OUT
- the given output type received by this peer. Any configured codec encoder must match
this type.configuringFunction
- a function will apply and return a Spec
to customize the peerpublic static <IN,OUT> TcpClient<IN,OUT> tcpClient(Class<? extends TcpClient> clientFactory, Function<? super Spec.TcpClientSpec<IN,OUT>,? extends Spec.TcpClientSpec<IN,OUT>> configuringFunction)
A TcpClient
is a specific kind of Publisher
that will emit:
- onNext ChannelStream
to consume data from
- onComplete when client is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
IN
- the given input type received by this peer. Any configured codec decoder must match
this type.OUT
- the given output type received by this peer. Any configured codec encoder must match
this type.clientFactory
- the given implementation class for this peerconfiguringFunction
- a function will apply and return a Spec
to customize the peerpublic static HttpServer<Buffer,Buffer> httpServer()
public static HttpServer<Buffer,Buffer> httpServer(String bindAddress)
bindAddress
- address to listen for (e.g. 0.0.0.0 or 127.0.0.1)public static HttpServer<Buffer,Buffer> httpServer(int port)
port
- the port to listen topublic static HttpServer<Buffer,Buffer> httpServer(String bindAddress, int port)
bindAddress
- address to listen for (e.g. 0.0.0.0 or 127.0.0.1)port
- the port to listen topublic static <IN,OUT> HttpServer<IN,OUT> httpServer(Function<? super Spec.HttpServerSpec<IN,OUT>,? extends Spec.HttpServerSpec<IN,OUT>> configuringFunction)
IN
- incoming data typeOUT
- outgoing data typeconfiguringFunction
- a factory to build server configuration (see also NetStreams.HttpServerFactory
public static <IN,OUT> HttpServer<IN,OUT> httpServer(Class<? extends HttpServer> serverFactory, Function<? super Spec.HttpServerSpec<IN,OUT>,? extends Spec.HttpServerSpec<IN,OUT>> configuringFunction)
IN
- incoming data typeOUT
- outgoing data typeserverFactory
- a target implementation server classconfiguringFunction
- a factory to build server configuration (see also NetStreams.HttpServerFactory
public static HttpClient<Buffer,Buffer> httpClient()
public static <IN,OUT> HttpClient<IN,OUT> httpClient(Function<? super Spec.HttpClientSpec<IN,OUT>,? extends Spec.HttpClientSpec<IN,OUT>> configuringFunction)
A HttpClient
is a specific kind of Publisher
that will
emit:
- onNext ChannelStream
to consume data from
- onComplete when client is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
IN
- the given input type received by this peer. Any configured codec decoder must match
this type.OUT
- the given output type received by this peer. Any configured codec encoder must match
this type.configuringFunction
- a function will apply and return a Spec
to customize the peerpublic static <IN,OUT> HttpClient<IN,OUT> httpClient(Class<? extends HttpClient> clientFactory, Function<? super Spec.HttpClientSpec<IN,OUT>,? extends Spec.HttpClientSpec<IN,OUT>> configuringFunction)
A HttpClient
is a specific kind of Publisher
that will
emit:
- onNext ChannelStream
to consume data from
- onComplete when client is shutdown
- onError when any exception (more specifically IO exception) occurs
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
IN
- the given input type received by this peer. Any configured codec decoder must match
this type.OUT
- the given output type received by this peer. Any configured codec encoder must match
this type.clientFactory
- the given implementation class for this peerconfiguringFunction
- a function will apply and return a Spec
to customize the peerpublic static DatagramServer<Buffer,Buffer> udpServer()
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
public static DatagramServer<Buffer,Buffer> udpServer(String bindAddress)
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
bindAddress
- bind address (e.g. "127.0.0.1") to create the server on the passed portpublic static DatagramServer<Buffer,Buffer> udpServer(int port)
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
port
- the port to listen on the passed bind addresspublic static DatagramServer<Buffer,Buffer> udpServer(String bindAddress, int port)
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
port
- the port to listen on the passed bind addressbindAddress
- bind address (e.g. "127.0.0.1") to create the server on the passed portpublic static <IN,OUT> DatagramServer<IN,OUT> udpServer(Function<? super Spec.DatagramServerSpec<IN,OUT>,? extends Spec.DatagramServerSpec<IN,OUT>> configuringFunction)
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
IN
- the given input type received by this peer. Any configured codec decoder must match
this type.OUT
- the given output type received by this peer. Any configured codec encoder must match
this type.configuringFunction
- a function will apply and return a Spec
to customize the peerpublic static <IN,OUT> DatagramServer<IN,OUT> udpServer(Class<? extends DatagramServer> serverFactory, Function<? super Spec.DatagramServerSpec<IN,OUT>,? extends Spec.DatagramServerSpec<IN,OUT>> configuringFunction)
From the emitted ReactorChannel
, one can decide to add in-channel consumers to read any incoming
data.
To reply data on the active connection, ReactorChannel.writeWith(org.reactivestreams.Publisher<? extends OUT>)
can subscribe to any passed Publisher
.
Note that Stream.getCapacity()
will be used to switch on/off a channel in auto-read / flush on
write mode.
If the capacity is Long.MAX_Value, write on flush and auto read will apply. Otherwise, data will be flushed every
capacity batch size and read will pause when capacity number of elements have been dispatched.
Emitted channels will run on the same thread they have beem receiving IO events.
Apart from dispatching the write, it is possible to use Stream.dispatchOn(reactor.Environment)
to process requests
asynchronously.
By default the type of emitted data or received data is Buffer
IN
- the given input type received by this peer. Any configured codec decoder must match
this type.OUT
- the given output type received by this peer. Any configured codec encoder must match
this type.serverFactory
- the given implementation class for this peerconfiguringFunction
- a function will apply and return a Spec
to customize the peerpublic static <E,IN,OUT> E delegate(ChannelStream<IN,OUT> channelStream)
public static <E,IN,OUT> E delegate(ChannelStream<IN,OUT> channelStream, Class<E> clazz)
public static Spec.IncrementalBackoffReconnect backoffReconnect()
Copyright © 2016. All rights reserved.