Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrStreamAlreadyRemoved is the error that a stream has already been removed ErrStreamAlreadyRemoved = errors.New("stream already removed") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // HardLoCap is low cap of stream number that immediately trigger discovery HardLoCap int // SoftLoCap is low cap of stream number that will trigger discovery during stream check SoftLoCap int // HiCap is the high cap of stream number HiCap int // DiscBatch is the size of each discovery DiscBatch int }
Config is the config for stream manager
type EvtStreamAdded ¶
EvtStreamAdded is the event of adding a new stream
type EvtStreamRemoved ¶
EvtStreamRemoved is an event of stream removed
type Operator ¶
type Operator interface { NewStream(stream sttypes.Stream) error RemoveStream(stID sttypes.StreamID) error }
Operator handles new stream or remove stream
type Reader ¶
type Reader interface { GetStreams() []sttypes.Stream GetStreamByID(id sttypes.StreamID) (sttypes.Stream, bool) }
Reader is the interface to read stream in stream manager
type ReaderSubscriber ¶
type ReaderSubscriber interface { Reader Subscriber }
ReaderSubscriber reads stream and subscribe stream events
type StreamManager ¶
type StreamManager interface { p2ptypes.LifeCycle Operator Subscriber Reader }
StreamManager is the interface for streamManager
func NewStreamManager ¶
func NewStreamManager(pid sttypes.ProtoID, host host, pf peerFinder, handleStream func(network.Stream), c Config) StreamManager
NewStreamManager creates a new stream manager for the given proto ID
type Subscriber ¶
type Subscriber interface { SubscribeAddStreamEvent(ch chan<- EvtStreamAdded) event.Subscription SubscribeRemoveStreamEvent(ch chan<- EvtStreamRemoved) event.Subscription }
Subscriber is the interface to support stream event subscription
Click to show internal directories.
Click to hide internal directories.