public abstract class NettyMessenger<R extends AbstractRequest,S extends AbstractResponse> extends Object implements Messenger<R,S>
Modifier | Constructor and Description |
---|---|
protected |
NettyMessenger(Options options)
Constructor for NettyMessenger.
|
Modifier and Type | Method and Description |
---|---|
protected CompletableFuture<NettyChannelContext> |
acquireContext(Object data)
Acquire context
|
protected <X> void |
applyDefault(Option<X> option,
X value)
Apply a default option value if not specified by the user
|
protected static NettyChannelContext |
attach(NettyChannelContext context,
AbstractRequest request)
Attach a request to the context
|
void |
close() |
protected abstract void |
configure(Options options)
Populate configuration options.
|
protected abstract NettyChannelFactory |
createChannelFactory()
createChannelFactory.
|
protected NettyChannelFactoryProvider |
createFactoryProvider()
createFactoryProvider.
|
NettyChannelFactory |
getChannelFactory()
Getter for the field
channelFactory . |
io.netty.channel.EventLoopGroup |
getExecutor()
The
Executor utilized by this messenger |
protected NettyChannelFactoryProvider |
getFactoryProvider()
Getter for the field
factoryProvider . |
Options |
getOptions()
getOptions.
|
NettyTransport |
getTransport()
The underlying
Transport used by this instance |
protected <X> void |
lockedOption(Options map,
Option<X> option,
X value)
Lock an option and prevent future updates for this option
|
protected void |
receive(@NotNull NettyChannelContext context,
AbstractResponse response,
Throwable error)
The method that will be called by the last
ChannelHandler once a response has been received from the remote server. |
<C extends NettyChannelContext> |
send(C context)
Send context to the underlying
Transport |
CompletableFuture<S> |
send(InetSocketAddress address,
R request)
Send request to the underlying
Transport |
protected Object |
transformProperties(InetSocketAddress address,
R request)
transformProperties.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
get, get, getOrDefault, getOrDefault, lock, set, unlock
protected abstract void configure(Options options)
options
- The Options
instance holding the configuration dataprotected NettyChannelFactoryProvider createFactoryProvider()
createFactoryProvider.
NettyChannelFactoryProvider
objectprotected abstract NettyChannelFactory createChannelFactory()
createChannelFactory.
NettyChannelFactory
objectpublic Options getOptions()
getOptions.
getOptions
in interface ConfigurationSupport
Options
objectpublic CompletableFuture<S> send(InetSocketAddress address, R request)
Send request to the underlying Transport
send
in interface Messenger<R extends AbstractRequest,S extends AbstractResponse>
address
- a InetSocketAddress
objectrequest
- a R objectCompletableFuture
objectprotected final CompletableFuture<NettyChannelContext> acquireContext(Object data)
Acquire context
data
- a Object
objectCompletableFuture
objectprotected Object transformProperties(InetSocketAddress address, R request)
transformProperties.
address
- a InetSocketAddress
objectrequest
- a R objectObject
objectprotected static NettyChannelContext attach(NettyChannelContext context, AbstractRequest request)
Attach a request to the context
context
- a NettyChannelContext
objectrequest
- a AbstractRequest
objectNettyChannelContext
objectpublic final <C extends NettyChannelContext> CompletableFuture<C> send(C context)
Send context to the underlying Transport
C
- A type of NettyChannelContext
context
- The context containing the transaction detailsCompletableFuture
objectpublic final NettyTransport getTransport()
The underlying Transport
used by this instance
getTransport
in interface Messenger<R extends AbstractRequest,S extends AbstractResponse>
Transport
objectpublic final io.netty.channel.EventLoopGroup getExecutor()
The Executor
utilized by this messenger
getExecutor
in interface Messenger<R extends AbstractRequest,S extends AbstractResponse>
Executor
object@ApiStatus.Internal protected void receive(@NotNull @NotNull NettyChannelContext context, AbstractResponse response, Throwable error)
ChannelHandler
once a response has been received from the remote server.context
- The NettyChannelContext
contianing all the important transaction details.error
- The error that occured during send/receive operation. null
if no error occured.response
- The decoded AbstractResponse
receivedpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public final NettyChannelFactory getChannelFactory()
Getter for the field channelFactory
.
NettyChannelFactory
objectprotected final NettyChannelFactoryProvider getFactoryProvider()
Getter for the field factoryProvider
.
NettyChannelFactoryProvider
objectprotected final <X> void lockedOption(Options map, Option<X> option, X value)
Lock an option and prevent future updates for this option
Copyright © 2016–2024. All rights reserved.