Replace this connection handler with the given handler.
Replace this connection handler with the given handler. The actual swap only occurs when the shutdown process complete
returns true if the client is potentially able to send.
returns true if the client is potentially able to send. This does not necessarily mean any new requests will actually be sent, but rather that the client will make an attempt to send it. This returns false when the client either failed to connect (including retries) or when it has been shut down.
This handler is called when a Worker new Connection is established.
This handler is called when a Worker new Connection is established. A Connection can be either an incoming (ie: something to connected to the server), or outgoing(ie: the server connected to a remote system).
The endpoint which wraps the java NIO layer.
Connection was closed on our end, either by a shutdown, or by normal means
Connection was closed on our end, either by a shutdown, or by normal means
why the connection was closed
Returns a read-only trait containing live information about the connection.
Returns a read-only trait containing live information about the connection.
Connection lost is caused by termination, closed, etc
Connection lost is caused by termination, closed, etc
why the connection was lost
Called from Worker when a connection has been terminated either by an error or by normal means.
Called from Worker when a connection has been terminated either by an error or by normal means.
why the connection was terminated
Close the underlying connection.
Close the underlying connection. This is a "graceful" disconnect process, in that any action mid-completion will be given a chance to finish what they're doing before the connection actually closes. For example, for a service this will allow any requests being processed to complete.
Immediately terminate the connection.
Immediately terminate the connection. this is a kill action and completely bypasses the shutdown process.
Called periodically on every attached connection handler, this can be used for checking if an ongoing operation has timed out.
Called periodically on every attached connection handler, this can be used for checking if an ongoing operation has timed out.
Be aware that this is totally independant of a connection's idle timeout, which is only based on the last time there was any I/O.
the frequency at which this method is called. Currently this is hardcoded to WorkerManager.IdleCheckFrequency
, but may become application dependent in the future.
If no data is either sent or received in this amount of time, the connection is closed.
If no data is either sent or received in this amount of time, the connection is closed. Defaults to Duration.Inf but handlers can override it
Called when the item is bound to a worker.
Called when the item is bound to a worker.
Called when the item has been unbound from a worker
Called when the item has been unbound from a worker
Pauses writing of the next item in the queue.
Pauses writing of the next item in the queue. If there is currently a message in the process of writing, it will be unaffected. New messages can still be pushed to the queue as long as it is not full
Purge all pending messages
Purge all pending messages
If a message is currently being written, it is not affected
Push a message to be written
Push a message to be written
Pushing a message does not necessarily mean it will be written, but rather that the message is queued to be written. Messages can be queue regardless of the state of the underlying connection, even if the connection is never reconnected. It is up to the caller to determine whether a message should be pushed based on connection state.
the message to push
the timestamp of when the message was created, defaults to now if not specified
called either when writing has completed or failed
true if the message was successfully enqueued, false if the queue is full
Handler which is called when data is received from a Connection.
Handler which is called when data is received from a Connection.
DataBuffer read from the underlying Connection.
Provides a way to send this WorkerItem a message from an Actor by way of WorkerCommand.Message.
Provides a way to send this WorkerItem a message from an Actor by way of WorkerCommand.Message.
The message that was sent
The sender who sent the message
Resumes writing of messages if currently paused, otherwise has no affect
Resumes writing of messages if currently paused, otherwise has no affect
Create a callback for sending a request.
Create a callback for sending a request. this allows you to do something like service.send("request"){response => "YAY"}.map{str => println(str)}.execute()
the connection handler should begin its graceful shutdown procedure.
the connection handler should begin its graceful shutdown procedure. For both servers and clients this can be triggered either by a call to gracefulDisconnect or to become. For ServerConnectionHandlers this can also occur when the Server begins shutting down.
A ServiceClient is a non-blocking, synchronous interface that handles sending atomic commands on a connection and parsing their replies
Notice - The client will not begin to connect until it is bound to a worker, so when using the default constructor a service client will not connect on it's own. You must either call
bind
on the client or use the constructor that accepts a workerTODO: make underlying output controller data size configurable