scheduler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interval

type Interval interface {
	FromNowWhenNext(policy types.PluginPolicy) (time.Time, error)
}

type NilService

type NilService struct{}

NilService implements the scheduler.Service for plugins where scheduling not required

func NewNilService

func NewNilService() *NilService

func (*NilService) Create

func (s *NilService) Create(_ context.Context, _ pgx.Tx, _ types.PluginPolicy) error

func (*NilService) Delete

func (s *NilService) Delete(_ context.Context, _ pgx.Tx, _ uuid.UUID) error

func (*NilService) Update

func (s *NilService) Update(_ context.Context, _ pgx.Tx, _, _ types.PluginPolicy) error

type PolicyFetcher

type PolicyFetcher interface {
	GetPluginPolicy(ctx context.Context, id uuid.UUID) (*types.PluginPolicy, error)
}

type Scheduler

type Scheduler struct {
	PolicyID      uuid.UUID `json:"policy_id"`
	NextExecution time.Time `json:"next_execution"`
}

type Service

type Service interface {
	Create(ctx context.Context, policy types.PluginPolicy) error
	Update(ctx context.Context, oldPolicy, newPolicy types.PluginPolicy) error
	Delete(ctx context.Context, policyID uuid.UUID) error
}

type Storage

type Storage interface {
	Tx() storage.Tx
	GetByPolicy(ctx context.Context, policyID uuid.UUID) (Scheduler, error)
	Create(ctx context.Context, policyID uuid.UUID, next time.Time) error
	Delete(ctx context.Context, policyID uuid.UUID) error
	GetPending(ctx context.Context) ([]Scheduler, error)
	SetNext(ctx context.Context, policyID uuid.UUID, next time.Time) error
}

type Worker

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

func NewWorker

func NewWorker(
	logger *logrus.Logger,
	client *asynq.Client,
	task,
	queue string,
	repo Storage,
	interval Interval,
	policy PolicyFetcher,
	schedulerMetrics metrics.SchedulerMetrics,
) *Worker

func (*Worker) Run

func (w *Worker) Run() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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