Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrTimeout is returned when the operation timeout is exceeded. ErrTimeout = errors.New("timeout") // ErrChannelClosed is returned when the input channel is closed. ErrChannelClosed = errors.New("channel closed") )
Functions ¶
This section is empty.
Types ¶
type CancelCallback ¶
type CancelCallback func(Future)
CancelCallback is a callback function executed when cancelling Future.
type Future ¶
type Future interface { // ID returns packet sequence number. ID() types.RequestID // Receiver returns the initiator of the packet. Receiver() *legacyhost.Host // Request returns origin request. Request() network.Packet // Response is a channel to listen for future response. Response() <-chan network.ReceivedPacket // SetResponse makes packet to appear in response channel. SetResponse(network.ReceivedPacket) // WaitResponse gets the future response from Response() channel with a timeout set to `duration`. WaitResponse(duration time.Duration) (network.ReceivedPacket, error) // Cancel closes all channels and cleans up underlying structures. Cancel() }
Future is network response future.
func NewFuture ¶
func NewFuture(requestID types.RequestID, receiver *legacyhost.Host, packet *rms.Packet, cancelCallback CancelCallback) Future
NewFuture creates a new Future.
type Manager ¶
func NewManager ¶
func NewManager() Manager
type PacketHandler ¶
type PacketHandler interface {
Handle(ctx context.Context, msg *packet.ReceivedPacket)
}
func NewPacketHandler ¶
func NewPacketHandler(futureManager Manager) PacketHandler
Click to show internal directories.
Click to hide internal directories.