workerpool

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.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 DBJob

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

DBJob represents the job to be run by a DBWorker from the pool.

func NewDBJob

func NewDBJob(bundle status.Bundle, metadata *conflator.BundleMetadata, handlerFunction conflator.BundleHandlerFunc,
	conflationUnitResultReporter conflator.ResultReporter,
) *DBJob

NewDBJob creates a new instance of DBJob.

type DBWorker

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

DBWorker worker within the DB Worker pool. runs as a goroutine and invokes DBJobs.

func NewDBWorker

func NewDBWorker(log logr.Logger, workerID int32, dbWorkersPool chan *DBWorker,
	dbConnPool postgres.StatusTransportBridgeDB, statistics *statistics.Statistics,
) *DBWorker

NewDBWorker creates a new instance of DBWorker. jobsQueue is initialized with capacity of 1. this is done in order to make sure dispatcher isn't blocked when calling to RunAsync, otherwise it will yield cpu to other go routines.

func (*DBWorker) RunAsync

func (worker *DBWorker) RunAsync(job *DBJob)

RunAsync runs DBJob and reports status to the given CU. once the job processing is finished worker returns to the worker pool in order to run more jobs.

type DBWorkerPool

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

DBWorkerPool pool that registers all db workers and the assigns db jobs to available workers.

func NewDBWorkerPool

func NewDBWorkerPool(dataConfig *config.DatabaseConfig, statistics *statistics.Statistics) (*DBWorkerPool, error)

NewDBWorkerPool returns a new db workers pool dispatcher.

func (*DBWorkerPool) Acquire

func (pool *DBWorkerPool) Acquire() (*DBWorker, error)

Acquire tries to acquire an available worker. if no worker is available, blocking until a worker becomes available.

func (*DBWorkerPool) Start

func (pool *DBWorkerPool) Start(ctx context.Context) error

Start function starts the db workers pool.

Jump to

Keyboard shortcuts

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