Documentation ¶
Overview ¶
Package streamutil provides utility functions to make handling streams easier.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingPeerID = errors.New("missing peer ID") ErrMissingProtocolIDs = errors.New("missing protocol IDs") )
Errors used by the stream provider.
var OptPeerID = func(peerID peer.ID) StreamOption { return func(opts *StreamOptions) { opts.PeerID = peerID } }
OptPeerID configures the remote peer.
var OptProtocolIDs = func(pids ...protocol.ID) StreamOption { return func(opts *StreamOptions) { opts.PIDs = pids } }
OptProtocolIDs configures the protocol IDs.
Functions ¶
func WithAutoClose ¶
func WithAutoClose(service string, method string, h AutoCloseHandler) inet.StreamHandler
WithAutoClose transforms an AutoCloseHandler to a StreamHandler.
Types ¶
type AutoCloseHandler ¶
AutoCloseHandler is a specialized stream handler that closes the stream when exiting. It automatically logs the handler error.
type Codec ¶
type Codec interface { multicodec.Encoder multicodec.Decoder }
Codec implements an Encoder and a Decoder.
func NewProtobufCodec ¶
NewProtobufCodec creates a Codec over the given stream, using protobuf as the message format.
type ProtobufCodec ¶
type ProtobufCodec struct { multicodec.Encoder multicodec.Decoder }
ProtobufCodec uses protobuf to encode messages.
type Provider ¶
Provider lets you configure streams with added features.
func NewStreamProvider ¶
func NewStreamProvider() Provider
NewStreamProvider returns a new provider.
type StreamOption ¶
type StreamOption func(opts *StreamOptions)
StreamOption configures a single stream option.
type StreamOptions ¶
StreamOptions are used to configure a stream.
type StreamProvider ¶
type StreamProvider struct{}
StreamProvider implements the Provider interface.
func (*StreamProvider) NewStream ¶
func (p *StreamProvider) NewStream(ctx context.Context, host ihost.Host, opts ...StreamOption) (Stream, error)
NewStream creates a new stream.
Directories ¶
Path | Synopsis |
---|---|
Package mockstream is a generated GoMock package.
|
Package mockstream is a generated GoMock package. |