broadcaster

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster struct {
	// contains filtered or unexported fields
}

Only a pointer to the struct should be used

func NewBroadcaster

func NewBroadcaster(c chan SocketData) *Broadcaster

Creates broadcaster from channel parameter and immediately starts broadcasting Without any subscribers, received data will be discarded Broadcaster should be the only channel reader

func (*Broadcaster) Expired

func (b *Broadcaster) Expired() bool

func (*Broadcaster) PoolSize

func (b *Broadcaster) PoolSize() (size int)

Iterates over sync.Map and returns number of elements Response can be oversized if counted subscriptions are cancelled while counting

func (*Broadcaster) Subscribe

func (b *Broadcaster) Subscribe() (*Subscriber, error)

Subscriber expected to constantly consume or unsubscribe

func (*Broadcaster) Unsubscribe

func (b *Broadcaster) Unsubscribe(sub *Subscriber) error

type Operation added in v0.18.0

type Operation string
const (
	Created Operation = "Created"
	Deleted Operation = "Deleted"
	Updated Operation = "Updated"
)

type SocketData

type SocketData struct {
	Kind      string      `json:"kind"`
	Operation Operation   `json:"operation"`
	Payload   interface{} `json:"payload"`
}

type Subscriber

type Subscriber struct {
	// contains filtered or unexported fields
}

Wrapper return type for subscriptions

func (*Subscriber) SubChan

func (s *Subscriber) SubChan() <-chan SocketData

Read-Only access to the subscription channel Open or nil, never closed

func (*Subscriber) UnsubChan

func (s *Subscriber) UnsubChan() <-chan struct{}

Closed on unsubscribe or when broadcast parent channel closes

Jump to

Keyboard shortcuts

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