runner

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	JobService      JobService
	Metrics         *metrics.RunnerMetrics
	ExecutorFactory executor.Factory
	Log             *otelzap.Logger
	InstanceId      string

	JobExecution JobExecutionSettings
}

type JobExecutionSettings

type JobExecutionSettings struct {
	Interval          time.Duration `conf:"default:10s" mapstructure:"interval" json:"interval,omitempty"`
	MaxConcurrentJobs int           `conf:"default:100" mapstructure:"maxConcurrentJobs" json:"maxConcurrentJobs,omitempty"`
	MaxJobLockTime    time.Duration `conf:"default:1m" mapstructure:"maxJobLockTime" json:"maxJobLockTime,omitempty"`
}

type JobService

type JobService interface {
	GetJobsToRun(ctx context.Context, at time.Time, lockedUntil time.Time, instanceID string, limit uint) ([]*model.Job, error)
	FinishJobExecution(ctx context.Context, job *model.Job, startTime, stopTime time.Time, err error) error
}

type Runner

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

func New

func New(cfg Config) *Runner

func (*Runner) Start

func (s *Runner) Start()

Start is a method to start the runner. It is safe to call this method multiple times. Only the first call will start the runner. Subsequent calls will be ignored.

func (*Runner) Stop

func (s *Runner) Stop(ctx context.Context)

Stop is a method to stop the runner, with a context to allow for a timeout. if the context has no deadline, default to a 10-second timeout.

Jump to

Keyboard shortcuts

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