R
- A type of AbstractRequest
S
- A type of AbstractResponse
public abstract class AbstractClient<R extends AbstractRequest,S extends AbstractResponse> extends Object implements Client
Client
interfaces.Modifier | Constructor and Description |
---|---|
protected |
AbstractClient(Options options)
Create a new client instance using the provided configuration options.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected abstract Messenger<R,S> |
createMessenger(Options options)
Factory method for
Messenger . |
Executor |
getExecutor()
The underlying
Executor used by this instance |
protected Messenger<R,S> |
getMessenger()
Getter for the field
messenger . |
Options |
getOptions() |
UUID |
id()
The unique-id of this instance
|
protected CompletableFuture<S> |
send(InetSocketAddress address,
R request)
Send request to messenger.
|
protected <V extends S> |
send(InetSocketAddress address,
R request,
Class<V> expectedResponse)
Send request.
|
protected AbstractClient(Options options)
options
- The Options
containing the configuration
options that will be used by the clientOptionBuilder
,
Options
protected <V extends S> CompletableFuture<V> send(InetSocketAddress address, R request, Class<V> expectedResponse)
V
- a V classaddress
- a InetSocketAddress
objectrequest
- a R objectexpectedResponse
- a Class
objectCompletableFuture
objectprotected final CompletableFuture<S> send(InetSocketAddress address, R request)
address
- The InetSocketAddress
destinationrequest
- The AbstractRequest
to be sentCompletableFuture
that is notified once a response has
been received.protected abstract Messenger<R,S> createMessenger(Options options)
Messenger
.public UUID id()
The unique-id of this instance
public Executor getExecutor()
The underlying Executor
used by this instance
getExecutor
in interface Client
Executor
objectprotected Messenger<R,S> getMessenger()
messenger
.Messenger
objectpublic final Options getOptions()
Options
used by this instancepublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2016–2024. All rights reserved.