pubsub

package module
v0.0.0-...-e58e4a5 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: MIT Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

func NewBuffer

func NewBuffer(minSize, maxReaders int) *Buffer

func (*Buffer) FullReadTo

func (b *Buffer) FullReadTo(rfn ReaderFunc) []interface{}

func (*Buffer) Read

func (b *Buffer) Read() []interface{}

func (*Buffer) ReadTo

func (b *Buffer) ReadTo(rfn ReaderFunc)

func (*Buffer) Write

func (b *Buffer) Write(v interface{})

func (*Buffer) WriteSlice

func (b *Buffer) WriteSlice(vs []interface{})

type Context

type Context struct {
	Buffer *Buffer
	Done   MarkerChan
	Close  func()
}

type Marker

type Marker byte
const (
	EmptyMarker Marker = iota
)

type MarkerChan

type MarkerChan chan struct{}

type PubSub

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

func New

func New(minBufferSize, maxSubCount int) (*PubSub, error)

func (*PubSub) AddPublisher

func (ps *PubSub) AddPublisher(pub Publisher) error

func (*PubSub) AddSubscriber

func (ps *PubSub) AddSubscriber(sub Subscriber) error

func (*PubSub) Close

func (ps *PubSub) Close()

func (*PubSub) Pub

func (ps *PubSub) Pub(v interface{}) error

func (*PubSub) PubChan

func (ps *PubSub) PubChan(ch <-chan interface{}) (<-chan struct{}, error)

func (*PubSub) PubSlice

func (ps *PubSub) PubSlice(vs []interface{}) error

func (*PubSub) SubChan

func (ps *PubSub) SubChan(ch chan<- interface{}) (chan<- struct{}, error)

func (*PubSub) SubFunc

func (ps *PubSub) SubFunc(fn func(interface{})) (func(), error)

type Publisher

type Publisher interface {
	PublishTo(ctx *Context) error
}

type ReaderFunc

type ReaderFunc func(interface{}) bool

type Subscriber

type Subscriber interface {
	SubscribeTo(ctx *Context) error
}

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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