dispatch

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultJobsLimit defines a maxiumum amount of jobs allowed in channel
	DefaultJobsLimit = 100

	// DefaultMaxWorkers is the package default worker ceiling amount
	DefaultMaxWorkers = 10

	// DefaultHandshakeTimeout defines a workers max length of time to wait on a
	// an unbuffered channel for a receiver before moving on to next route
	DefaultHandshakeTimeout = 200 * time.Nanosecond
)
View Source
const Name = "dispatch"

Name is an exported subsystem name

Variables

View Source
var ErrNotRunning = errors.New("dispatcher not running")

ErrNotRunning defines an error when the dispatcher is not running

Functions

func DropWorker

func DropWorker() error

DropWorker drops a worker routine

func IsRunning

func IsRunning() bool

IsRunning checks to see if the dispatch service is running

func SpawnWorker

func SpawnWorker() error

SpawnWorker starts a new worker routine

func Start

func Start(workers, jobsLimit int) error

Start starts the dispatch system by spawning workers and allocating memory

func Stop

func Stop() error

Stop attempts to stop the dispatch service, this will close all pipe channels flush job list and drop all workers

Types

type Dispatcher

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

Dispatcher defines an internal subsystem communication/change state publisher

type Mux

type Mux struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Mux defines a new multiplexer for the dispatch system, these a generated per subsystem

func GetNewMux

func GetNewMux() *Mux

GetNewMux returns a new multiplexer to track subsystem updates

func (*Mux) GetID

func (m *Mux) GetID() (uuid.UUID, error)

GetID a new unique ID to track routing information in the dispatch system

func (*Mux) Publish

func (m *Mux) Publish(ids []uuid.UUID, data interface{}) error

Publish takes in a persistent memory address and dispatches changes to required pipes. Data should be of *type.

func (*Mux) Subscribe

func (m *Mux) Subscribe(id uuid.UUID) (Pipe, error)

Subscribe takes in a package defined signature element pointing to an ID set and returns the associated pipe

func (*Mux) Unsubscribe

func (m *Mux) Unsubscribe(id uuid.UUID, ch chan interface{}) error

Unsubscribe returns channel to the pool for the full signature set

type Pipe

type Pipe struct {
	// Channel to get all our lovely informations
	C chan interface{}
	// contains filtered or unexported fields
}

Pipe defines an outbound object to the desired routine

func (*Pipe) Release

func (p *Pipe) Release() error

Release returns the channel to the communications pool to be reused

Jump to

Keyboard shortcuts

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