Documentation
¶
Overview ¶
Package requestbuffer provides a storage for a consistent set of Request and corresponding Reply messages. It allows to asynchronously add and remove messages, as well as to subscribe for new messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type T ¶
type T struct {
// contains filtered or unexported fields
}
T implements the storage to keep and coordinate flow and processing of Request and Reply messages. All methods are safe to invoke concurrently. Current implementation has capacity for a single request only.
func (*T) AddReply ¶
AddReply adds a new Reply message to the buffer. Messages with no corresponding Request message in the buffer will be dropped. Any subsequent Reply message with the same replica ID corresponding to the same Request will be dropped. The return value indicates if the message was accepted.
func (*T) AddRequest ¶
AddRequest adds a new Request message to the buffer. Each subsequent invocation should supply a message with increasing non-zero sequence ID. It will block if there's no capacity available for the new message. The corresponding Reply messages are to be received from the returned channel as they are added with AddReply. The returned channel is closed when RemoveRequest is invoked for the Request message. The returned boolean value indicates if the message was accepted.
func (*T) RemoveRequest ¶
RemoveRequest removes a Request message and all corresponding Reply messages given a sequence ID of the Request message.
func (*T) RequestStream ¶
RequestStream returns a channel to receive all Request messages as they are added with AddRequest. Closing the channel passed to this function indicates the returned channel should be closed. Nil channel may be passed if there's no need to close the returned channel.