workerpool

package
v0.0.0-...-b8ff696 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecutionFn

type ExecutionFn func(ctx context.Context, fnParam FnParam) error

type FnParam

type FnParam struct {
	Logger   *slog.Logger
	Tgbot    *bot.Bot
	Repo     repository.Repository
	Settings *models.Settings
}

type Job

type Job struct {
	context.Context

	ID       JobID
	Settings *models.Settings
	ExecFn   ExecutionFn
	// contains filtered or unexported fields
}

type JobID

type JobID int64

type WorkerPool

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

func New

func New(ctx context.Context, wg *sync.WaitGroup, logger *slog.Logger, repo repository.Repository) (*WorkerPool, error)

func (*WorkerPool) Add

func (wp *WorkerPool) Add(ctx context.Context, settings *models.Settings, execFn ExecutionFn) JobID

func (*WorkerPool) Close

func (wp *WorkerPool) Close() error

func (*WorkerPool) Delete

func (wp *WorkerPool) Delete(ctx context.Context, jobID JobID)

func (*WorkerPool) GenerateFrom

func (wp *WorkerPool) GenerateFrom(jobsBulk []Job)

func (*WorkerPool) Run

func (wp *WorkerPool) Run(wg *sync.WaitGroup)

func (*WorkerPool) SetTgBot

func (wp *WorkerPool) SetTgBot(tgbot *bot.Bot)

Jump to

Keyboard shortcuts

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