Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Batcher ¶ added in v0.0.20
type Batcher[T any, U any] struct { FlushPeriod time.Duration Joiner func(inputs []T) (outputs U) // contains filtered or unexported fields }
func NewBatcher ¶ added in v0.0.20
func NewIDBatcher ¶ added in v0.0.20
func (*Batcher[T, U]) InputChannel ¶ added in v0.0.20
func (fo *Batcher[T, U]) InputChannel() chan<- T
type BatcherCmd ¶ added in v0.0.21
type FanOut ¶
type FanOut[T any, U any] struct { Mapper func(inputs T) U // contains filtered or unexported fields }
*
- FanOut takes a message from one chanel, applies a mapper function
- and fans it out to N output channels.
func (*FanOut[T, U]) InputChannel ¶ added in v0.0.19
func (fo *FanOut[T, U]) InputChannel() chan<- T
type Hub ¶ added in v0.0.30
type Hub[M any] struct { // contains filtered or unexported fields }
type HubClient ¶ added in v0.0.30
type HubClient[M any] struct { WriteMessage func(HubMessage[M]) error // contains filtered or unexported fields }
func (*HubClient[M]) Disconnect ¶ added in v0.0.30
func (h *HubClient[M]) Disconnect()
func (*HubClient[M]) Unsubscribe ¶ added in v0.0.30
type HubControlEvent ¶ added in v0.0.30
type HubMessage ¶ added in v0.0.30
type HubWriter ¶ added in v0.0.30
type HubWriter[M any] func(HubMessage[M]) error
type KVRouter ¶ added in v0.0.30
type KVRouter[M any] struct { // contains filtered or unexported fields }
*
- A type of router that maintains an eventKey -> Conn[] by
- a fixed event keys.
func NewKVRouter ¶ added in v0.0.30
func (*KVRouter[M]) RemoveRoute ¶ added in v0.0.30
func (*KVRouter[M]) RouteMessage ¶ added in v0.0.30
func (r *KVRouter[M]) RouteMessage(msg HubMessage[M]) error
type ReaderChan ¶
type ReaderChan[R any, D any] struct { ReaderWriterBase[R, D] Read func() (R, error) // contains filtered or unexported fields }
func (*ReaderChan[R, D]) IsRunning ¶
func (ch *ReaderChan[R, D]) IsRunning() bool
*
- Returns whether the connection reader/writer loops are running.
func (*ReaderChan[R, D]) ResultChannel ¶ added in v0.0.19
func (rc *ReaderChan[R, D]) ResultChannel() chan ValueOrError[R]
*
- Returns the conn's reader channel.
func (*ReaderChan[T, D]) Stop ¶
func (ch *ReaderChan[T, D]) Stop() error
*
- This method is called to stop the channel
- If already connected then nothing is done and nil
- is not already connected, a connection will first be established
- (including auth and refreshing tokens) and then the reader and
- writers are started. SendRequest can be called to send requests
- to the peer and the (user provided) msgChannel will be used to
- handle messages from the server.
type ReaderWriterBase ¶
type ReaderWriterBase[T any, D any] struct { Info D // Time allowed to read the next pong message from the peer. WaitTime time.Duration // contains filtered or unexported fields }
func (*ReaderWriterBase[T, D]) WaitForFinish ¶
func (rwb *ReaderWriterBase[T, D]) WaitForFinish()
*
- Waits until the socket connection is disconnected or manually stopped.
type Router ¶ added in v0.0.30
type Router[M any] interface { AddRoute(client *HubClient[M], eventKeys ...string) error RemoveRoute(client *HubClient[M], eventKeys ...string) error Remove(client *HubClient[M]) error RouteMessage(HubMessage[M]) error }
*
- In our streamer the main problem is given a message, identifying
- all connections it should be sent to. Instead of having a fixed
- key -> HubClient[] mapping, it is easier to simply for each
- message use a router delegate to identify all HubClients that
- are candidates. This Router does that.
type ValueOrError ¶
type WriterChan ¶
type WriterChan[W any, D any] struct { ReaderWriterBase[W, D] Write func(msg W) error OnClose func() // contains filtered or unexported fields }
func (*WriterChan[W, D]) IsRunning ¶
func (ch *WriterChan[W, D]) IsRunning() bool
*
- Returns whether the connection reader/writer loops are running.
func (*WriterChan[W, D]) Send ¶
func (wc *WriterChan[W, D]) Send(req W) bool
func (*WriterChan[T, D]) Stop ¶
func (ch *WriterChan[T, D]) Stop() error
*
- This method is called to stop the channel
- If already connected then nothing is done and nil
- is not already connected, a connection will first be established
- (including auth and refreshing tokens) and then the reader and
- writers are started. SendRequest can be called to send requests
- to the peer and the (user provided) msgChannel will be used to
- handle messages from the server.
Click to show internal directories.
Click to hide internal directories.