scheduler

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultInterval added in v0.1.16

type DefaultInterval struct{}

DefaultInterval provides a standard implementation of the Interval interface. Plugins can use this directly or implement their own custom logic.

func NewDefaultInterval added in v0.1.16

func NewDefaultInterval() *DefaultInterval

NewDefaultInterval creates a new DefaultInterval instance.

func (*DefaultInterval) FromNowWhenNext added in v0.1.16

func (i *DefaultInterval) FromNowWhenNext(policy types.PluginPolicy) (time.Time, error)

FromNowWhenNext calculates when the next execution should occur based on the policy's recipe configuration. Returns zero time if there should be no more executions (policy expired or one-time completed).

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 (*NilService) Delete

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

func (*NilService) Update

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

type PolicyFetcher

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

type SafetyManager added in v0.1.16

type SafetyManager interface {
	EnforceKeysign(ctx context.Context, pluginID string) 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,
	safety SafetyManager,
) *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