streammanager

package
v0.0.0-...-3da4c06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2022 License: LGPL-3.0 Imports: 18 Imported by: 0

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

type EvtStreamAdded struct {
	Stream sttypes.Stream
}

EvtStreamAdded is the event of adding a new stream

type EvtStreamRemoved

type EvtStreamRemoved struct {
	ID sttypes.StreamID
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL