supervisor

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2022 License: GPL-3.0 Imports: 1 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Publisher

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

Publisher publishes tasks carrying the provided function to the queueManager, Which will pass the task on to a worker which runs the task using the provided parameters.

func (*Publisher) Publish

func (p *Publisher) Publish(data any)

Publish publishes a new task with the function provided during the creation of the Publisher. The task will be run using the data provided.

type Supervisor

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

Supervisor starts, registers and shuts down workers.

func NewSupervisor

func NewSupervisor(numberOfWorkers int) *Supervisor

NewSupervisor creates a new Supervisor instance and amount of workers equal to numberOfWorkers.

func (*Supervisor) Register

func (sv *Supervisor) Register(
	f func(p *Publisher, d any, rch chan any),
) (*Publisher, chan any)

Register registers a new function and returns an instance of Publisher. This Publisher instance publishes new tasks that'll be run within the provided function.

func (*Supervisor) Shutdown

func (sv *Supervisor) Shutdown()

Shutdown gracefully shuts down all workers. Run Shutdown in a separate routine in case you do not want to wait for Shutdown to finish. No new tasks should be published after Shutdown has been called.

Jump to

Keyboard shortcuts

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