period

package
v0.0.0-...-e417875 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 18 Imported by: 120

Documentation

Index

Constants

View Source
const (

	// PeriodicExecutionMark marks the scheduled job to a periodic execution
	PeriodicExecutionMark = "_job_kind_periodic_"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MockScheduler

type MockScheduler struct {
	mock.Mock
}

MockScheduler is an autogenerated mock type for the Scheduler type

func NewMockScheduler

func NewMockScheduler(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockScheduler

NewMockScheduler creates a new instance of MockScheduler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockScheduler) Schedule

func (_m *MockScheduler) Schedule(policy *Policy) (int64, error)

Schedule provides a mock function with given fields: policy

func (*MockScheduler) Start

func (_m *MockScheduler) Start()

Start provides a mock function with given fields:

func (*MockScheduler) UnSchedule

func (_m *MockScheduler) UnSchedule(policyID string) error

UnSchedule provides a mock function with given fields: policyID

type Policy

type Policy struct {
	// Policy can be treated as job template of periodic job.
	// The info of policy will be copied into the scheduled job executions for the periodic job.
	ID            string                 `json:"id"`
	JobName       string                 `json:"job_name"`
	CronSpec      string                 `json:"cron_spec"`
	JobParameters map[string]interface{} `json:"job_params,omitempty"`
	WebHookURL    string                 `json:"web_hook_url,omitempty"`
	NumericID     int64                  `json:"numeric_id,omitempty"`
}

Policy ...

func Load

func Load(namespace string, conn redis.Conn) ([]*Policy, error)

Load all the policies from the backend storage.

func (*Policy) DeSerialize

func (p *Policy) DeSerialize(rawJSON []byte) error

DeSerialize the raw json to policy.

func (*Policy) Serialize

func (p *Policy) Serialize() ([]byte, error)

Serialize the policy to raw data.

func (*Policy) Validate

func (p *Policy) Validate() error

Validate the policy

type Scheduler

type Scheduler interface {
	// Start to serve periodic job scheduling process
	//
	Start()

	// Schedule the specified cron job policy.
	//
	// policy *Policy           : The job template of the scheduling periodical jobs
	//
	// Returns:
	//  int64 the numeric id of policy
	//  error if failed to schedule
	Schedule(policy *Policy) (int64, error)

	// Unschedule the specified cron job policy.
	//
	// policyID string: The ID of cron job policy.
	//
	// Return:
	//  error if failed to unschedule
	UnSchedule(policyID string) error
}

Scheduler defines operations the periodic scheduler should have.

func NewScheduler

func NewScheduler(ctx context.Context, namespace string, pool *redis.Pool, ctl lcm.Controller) Scheduler

NewScheduler is constructor of basicScheduler

Jump to

Keyboard shortcuts

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