dispatch

package
v0.0.0-...-0676c78 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 7 Imported by: 19

Documentation

Index

Constants

View Source
const (
	// DefaultJobsLimit defines a maximum 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 defines an error when the dispatcher is not running
	ErrNotRunning = errors.New("dispatcher not running")
)

Functions

func IsRunning

func IsRunning() bool

IsRunning checks to see if the dispatch service is running

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

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher creates a new Dispatcher for relaying data.

type Mux

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

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

func GetNewMux

func GetNewMux(d *Dispatcher) *Mux

GetNewMux returns a new multiplexer to track subsystem updates, if nil dispatcher provided it will default to the global Dispatcher.

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(data interface{}, ids ...uuid.UUID) error

Publish takes in a persistent memory address and dispatches changes to required pipes.

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 {
	// contains filtered or unexported fields
}

Pipe defines an outbound object to the desired routine

func (*Pipe) Channel

func (p *Pipe) Channel() <-chan interface{}

Channel returns the Pipe's channel

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