cron

package
v2.27.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package cron is a generated GoMock package.

Package cron is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cron

type Cron interface {
	// Start the cron scheduler
	Start() (<-chan *Execution, error)
	// Stop the cron scheduler
	Stop()
	// Schedule an event to be executed on its schedule. This should
	// be called when adding events outside of Reload operations.
	// This method is idempotent and can be used to update existing schedules
	// of events as well as add new events.
	Schedule(event Event)
	// Unschedule an event from the scheduler.
	Unschedule(event string)
}

Cron is an interface for scheduling recurring events to be triggered. When Start is called, a channel will be returned that will be populated with Execution objects for each event that is triggered according to its schedule.

func New

func New(scheduler Scheduler, loadEvents LoadEvents, logger log.Logger) Cron

New creates a new instance of Cron with the specified parameters

type Event

type Event interface {
	Schedule
	// GetID is a unique identifier for this event that can be
	// used to update or remove it from the scheduler.
	GetID() string
}

Event that can be scheduled for execution at a specific time.

type Execution

type Execution struct {
	// Event id that was executed
	Event Event
	// Time the event was executed
	Time int64
}

Execution represents an event execution and the result

type LoadEvents

type LoadEvents func(qb.LimitOffset) ([]Event, int, error)

LoadEvents for scheduling in an instance of Cron

type MockCron

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

MockCron is a mock of Cron interface.

func NewMockCron

func NewMockCron(ctrl *gomock.Controller) *MockCron

NewMockCron creates a new mock instance.

func (*MockCron) EXPECT

func (m *MockCron) EXPECT() *MockCronMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockCron) Schedule

func (m *MockCron) Schedule(event Event)

Schedule mocks base method.

func (*MockCron) Start

func (m *MockCron) Start() (<-chan *Execution, error)

Start mocks base method.

func (*MockCron) Stop

func (m *MockCron) Stop()

Stop mocks base method.

func (*MockCron) Unschedule

func (m *MockCron) Unschedule(event string)

Unschedule mocks base method.

type MockCronMockRecorder

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

MockCronMockRecorder is the mock recorder for MockCron.

func (*MockCronMockRecorder) Schedule

func (mr *MockCronMockRecorder) Schedule(event any) *gomock.Call

Schedule indicates an expected call of Schedule.

func (*MockCronMockRecorder) Start

func (mr *MockCronMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start.

func (*MockCronMockRecorder) Stop

func (mr *MockCronMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop.

func (*MockCronMockRecorder) Unschedule

func (mr *MockCronMockRecorder) Unschedule(event any) *gomock.Call

Unschedule indicates an expected call of Unschedule.

type MockEvent

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

MockEvent is a mock of Event interface.

func NewMockEvent

func NewMockEvent(ctrl *gomock.Controller) *MockEvent

NewMockEvent creates a new mock instance.

func (*MockEvent) EXPECT

func (m *MockEvent) EXPECT() *MockEventMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockEvent) GetDayOfMonth

func (m *MockEvent) GetDayOfMonth() int32

GetDayOfMonth mocks base method.

func (*MockEvent) GetDayOfWeek

func (m *MockEvent) GetDayOfWeek() int32

GetDayOfWeek mocks base method.

func (*MockEvent) GetHour

func (m *MockEvent) GetHour() int32

GetHour mocks base method.

func (*MockEvent) GetID

func (m *MockEvent) GetID() string

GetID mocks base method.

func (*MockEvent) GetMinute

func (m *MockEvent) GetMinute() int32

GetMinute mocks base method.

func (*MockEvent) GetMonth

func (m *MockEvent) GetMonth() int32

GetMonth mocks base method.

type MockEventMockRecorder

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

MockEventMockRecorder is the mock recorder for MockEvent.

func (*MockEventMockRecorder) GetDayOfMonth

func (mr *MockEventMockRecorder) GetDayOfMonth() *gomock.Call

GetDayOfMonth indicates an expected call of GetDayOfMonth.

func (*MockEventMockRecorder) GetDayOfWeek

func (mr *MockEventMockRecorder) GetDayOfWeek() *gomock.Call

GetDayOfWeek indicates an expected call of GetDayOfWeek.

func (*MockEventMockRecorder) GetHour

func (mr *MockEventMockRecorder) GetHour() *gomock.Call

GetHour indicates an expected call of GetHour.

func (*MockEventMockRecorder) GetID

func (mr *MockEventMockRecorder) GetID() *gomock.Call

GetID indicates an expected call of GetID.

func (*MockEventMockRecorder) GetMinute

func (mr *MockEventMockRecorder) GetMinute() *gomock.Call

GetMinute indicates an expected call of GetMinute.

func (*MockEventMockRecorder) GetMonth

func (mr *MockEventMockRecorder) GetMonth() *gomock.Call

GetMonth indicates an expected call of GetMonth.

type Result

type Result string

Result of an event execution

const (
	// Success indicates that the event was executed successfully with no error
	Success Result = "success"
	// Failure indicates that the event failed to execute due to an error
	Failure Result = "failure"
)

type Schedule

type Schedule interface {
	// GetMinute of execution, [0,59]
	GetMinute() int32
	// GetDayOfWeek of execution [1,7]
	GetDayOfWeek() int32
	// GetDayOfMonth of execution [1,31]
	GetDayOfMonth() int32
	// GetMonth of execution, [1,12]
	GetMonth() int32
	// GetHour of execution [0,23]
	GetHour() int32
}

Schedule for an Event to be executed on. Negative values indicate that the field is not applicable.

type Scheduler

type Scheduler interface {
	// GetNextExecution determines the next execution time based on the provided schedule and returns.
	// All times are UTC.
	GetNextExecution(schedule Schedule) time.Time
}

Scheduler determines the next execution time based on the provided schedule.

func NewScheduler

func NewScheduler() Scheduler

NewScheduler creates a new Scheduler instance.

Jump to

Keyboard shortcuts

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