workers

package module
v0.0.0-...-c89a89c Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: MIT Imports: 12 Imported by: 0

README

workers

AFAIRE


Copyright (c) 2022-2023 Archivage Numérique

Documentation

Index

Constants

View Source
const (
	MaxPoolSize = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PoolSize uint `dm:"pool_size"`
	Logger   *logger.Logger
	Runner   Runner
	// contains filtered or unexported fields
}

type Job

type Job struct {
	ID         string       `json:"id"`
	Namespace  string       `json:"namespace"`
	Type       string       `json:"type"`
	ExternalID string       `json:"external_id"`
	Name       string       `json:"name"`
	Version    uint         `json:"version"`
	Origin     string       `json:"origin"`
	Priority   sdk.Priority `json:"priority"`
	Session    uint         `json:"session"`
	Attempt    uint         `json:"attempt"`
	StartedAt  time.Time    `json:"started_at"`
	FinishedAt time.Time    `json:"finished_at"`
}

type Runner

type Runner interface {
	NextJob(host, worker string) *sdk.Job
	RunJob(logger *logger.Logger, job *sdk.Job) error
	UpdateJob(jtu *sdk.JobToUpdate) (*sdk.Job, *sdk.Job)
}

type WorkerState

type WorkerState struct {
	ID          string    `json:"id"`
	CreatedAt   time.Time `json:"created_at"`
	Temporary   bool      `json:"temporary"`
	Interrupted bool      `json:"interrupted"`
	Busy        bool      `json:"busy"`
	Job         *Job      `json:"job"`
	Counter     uint      `json:"counter"`
}

type Workers

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

func New

func New(cfg *Config) (*Workers, error)

func (*Workers) Interrupt

func (ws *Workers) Interrupt() error

func (*Workers) InterruptWorker

func (ws *Workers) InterruptWorker(id string) error

func (*Workers) Resume

func (ws *Workers) Resume() error

func (*Workers) ResumeWorker

func (ws *Workers) ResumeWorker(id string) error

func (*Workers) Start

func (ws *Workers) Start() error

func (*Workers) StartWorker

func (ws *Workers) StartWorker(temporary, interrupted bool) (string, error)

func (*Workers) State

func (ws *Workers) State() ([]*WorkerState, error)

func (*Workers) Stop

func (ws *Workers) Stop() error

func (*Workers) StopWorker

func (ws *Workers) StopWorker(id string) error

Jump to

Keyboard shortcuts

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