Documentation
¶
Index ¶
Constants ¶
View Source
const CName = "common.net.streampool"
Variables ¶
View Source
var ( // EncodingProto drpc.Encoding implementation for gogo protobuf EncodingProto drpc.Encoding = protoEncoding{} )
Functions ¶
This section is empty.
Types ¶
type ExecPool ¶ added in v0.1.2
type ExecPool struct {
// contains filtered or unexported fields
}
ExecPool needed for parallel execution of the incoming send tasks
func NewExecPool ¶ added in v0.1.2
NewExecPool creates new ExecPool workers - how many processes will execute tasks maxSize - limit for queue size
type MessageQueueId ¶
type PeerGetter ¶
PeerGetter should dial or return cached peers
type Service ¶
type Service interface {
NewStreamPool(h StreamHandler, conf StreamConfig) StreamPool
app.Component
}
type SizeableMessage ¶ added in v0.3.9
type SizeableMessage interface {
Size() int
}
type StreamConfig ¶
type StreamHandler ¶
type StreamHandler interface {
// OpenStream opens stream with given peer
OpenStream(ctx context.Context, p peer.Peer) (stream drpc.Stream, tags []string, err error)
// HandleMessage handles incoming message
HandleMessage(ctx context.Context, peerId string, msg drpc.Message) (err error)
// NewReadMessage creates new empty message for unmarshalling into it
NewReadMessage() drpc.Message
}
StreamHandler handles incoming messages from streams
type StreamPool ¶
type StreamPool interface {
// AddStream adds new outgoing stream into the pool
AddStream(stream drpc.Stream, tags ...string) (err error)
// ReadStream adds new incoming stream and synchronously read it
ReadStream(stream drpc.Stream, tags ...string) (err error)
// Send sends a message to given peers. A stream will be opened if it is not cached before. Works async.
Send(ctx context.Context, msg drpc.Message, target PeerGetter) (err error)
// SendById sends a message to given peerIds. Works only if stream exists
SendById(ctx context.Context, msg drpc.Message, peerIds ...string) (err error)
// Broadcast sends a message to all peers with given tags. Works async.
Broadcast(ctx context.Context, msg drpc.Message, tags ...string) (err error)
// AddTagsCtx adds tags to stream, stream will be extracted from ctx
AddTagsCtx(ctx context.Context, tags ...string) error
// RemoveTagsCtx removes tags from stream, stream will be extracted from ctx
RemoveTagsCtx(ctx context.Context, tags ...string) error
// Streams gets all streams for specific tags
Streams(tags ...string) (streams []drpc.Stream)
// Close closes all streams
Close() error
}
StreamPool keeps and read streams
Source Files
¶
Click to show internal directories.
Click to hide internal directories.