workers

package
v0.17.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FnWorker added in v0.16.0

type FnWorker struct {

	// Queue is the fn queue that FnWorker
	// will feed from for upcoming tasks.
	Queue *queue.SimpleQueue[func(context.Context)]
	// contains filtered or unexported fields
}

FnWorker wraps a queue.SimpleQueue{} which it feeds from to provide it with function tasks to execute. It does so in a single goroutine with state management utilities.

func (*FnWorker) Start added in v0.16.0

func (w *FnWorker) Start() bool

Start will attempt to start the Worker{}.

func (*FnWorker) Stop added in v0.16.0

func (w *FnWorker) Stop() bool

Stop will attempt to stop the Worker{}.

type FnWorkerPool added in v0.16.0

type FnWorkerPool struct {

	// Queue is embedded queue.SimpleQueue{}
	// passed to each of the pool Worker{}s.
	Queue queue.SimpleQueue[func(context.Context)]
	// contains filtered or unexported fields
}

FnWorkerPool wraps multiple FnWorker{}s in a singular struct for easy multi start / stop.

func (*FnWorkerPool) Start added in v0.16.0

func (p *FnWorkerPool) Start(n int)

Start will attempt to start 'n' FnWorker{}s.

func (*FnWorkerPool) Stop added in v0.16.0

func (p *FnWorkerPool) Stop()

Stop will attempt to stop contained FnWorker{}s.

type MsgWorker added in v0.16.0

type MsgWorker[Msg any] struct {

	// Process handles queued message types.
	Process func(context.Context, Msg) error

	// Queue is the Delivery{} message queue
	// that delivery worker will feed from.
	Queue *queue.StructQueue[Msg]
	// contains filtered or unexported fields
}

MsgWorker wraps a processing function to feed from a queue.StructQueue{} for messages to process. It does so in a single goroutine with state management utilities.

func (*MsgWorker[T]) Start added in v0.16.0

func (w *MsgWorker[T]) Start() bool

Start will attempt to start the Worker{}.

func (*MsgWorker[T]) Stop added in v0.16.0

func (w *MsgWorker[T]) Stop() bool

Stop will attempt to stop the Worker{}.

type MsgWorkerPool added in v0.16.0

type MsgWorkerPool[Msg any] struct {

	// Process handles queued message types.
	Process func(context.Context, Msg) error

	// Queue is embedded queue.StructQueue{}
	// passed to each of the pool Worker{}s.
	Queue queue.StructQueue[Msg]
	// contains filtered or unexported fields
}

MsgWorkerPool wraps multiple MsgWorker{}s in a singular struct for easy multi start / stop.

func (*MsgWorkerPool[T]) Init added in v0.16.0

func (p *MsgWorkerPool[T]) Init(indices []structr.IndexConfig)

Init will initialize the worker pool queue with given struct indices.

func (*MsgWorkerPool[T]) Start added in v0.16.0

func (p *MsgWorkerPool[T]) Start(n int)

Start will attempt to start 'n' Worker{}s.

func (*MsgWorkerPool[T]) Stop added in v0.16.0

func (p *MsgWorkerPool[T]) Stop()

Stop will attempt to stop contained Worker{}s.

type Workers

type Workers struct {
	// Main task scheduler instance.
	Scheduler scheduler.Scheduler

	// Delivery provides a worker pool that
	// handles outgoing ActivityPub deliveries.
	// It contains an embedded (but accessible)
	// indexed queue of Delivery{} objects.
	Delivery delivery.WorkerPool

	// Client provides a worker pool that handles
	// incoming processing jobs from the client API.
	Client MsgWorkerPool[*messages.FromClientAPI]

	// Federator provides a worker pool that handles
	// incoming processing jobs from the fedi API.
	Federator MsgWorkerPool[*messages.FromFediAPI]

	// Dereference provides a worker pool
	// for asynchronous dereferencer jobs.
	Dereference FnWorkerPool

	// Processing provides a worker pool
	// for asynchronous processing jobs,
	// eg., import tasks, admin tasks.
	Processing FnWorkerPool
	// contains filtered or unexported fields
}

func (*Workers) Start

func (w *Workers) Start()

Start will start contained worker pools.

func (*Workers) StartScheduler added in v0.16.0

func (w *Workers) StartScheduler()

StartScheduler starts the job scheduler.

func (*Workers) Stop

func (w *Workers) Stop()

Stop will stop all of the contained worker pools (and global scheduler).

Jump to

Keyboard shortcuts

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