period

package
v1.7.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventSchedulePeriodicPolicy is for scheduling periodic policy event
	EventSchedulePeriodicPolicy = "schedule"
	// EventUnSchedulePeriodicPolicy is for unscheduling periodic policy event
	EventUnSchedulePeriodicPolicy = "unschedule"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Schedule the specified cron job policy.
	//
	// jobName string           : The name of periodical job
	// params models.Parameters : The parameters required by the periodical job
	// cronSpec string          : The periodical settings with cron format
	//
	// Returns:
	//  The uuid of the cron job policy
	//  The latest next trigger time
	//  error if failed to schedule
	Schedule(jobName string, params models.Parameters, cronSpec string) (string, int64, error)

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

	// Load and cache data if needed
	//
	// Return:
	//  error if failed to do
	Load() error

	// Clear all the cron job policies.
	//
	// Return:
	//  error if failed to do
	Clear() error

	// Start to serve
	Start()

	// Accept the pushed policy and cache it
	//
	// policy *PeriodicJobPolicy : the periodic policy being accept
	//
	// Return:
	//  error if failed to do
	AcceptPeriodicPolicy(policy *PeriodicJobPolicy) error

	// Remove the specified policy from the cache if it is existing
	//
	// policyID string : ID of the policy being removed
	//
	// Return:
	//  the ptr of the being deletd policy
	RemovePeriodicPolicy(policyID string) *PeriodicJobPolicy
}

Interface defines operations the periodic scheduler should have.

type PeriodicJobPolicy

type PeriodicJobPolicy struct {
	// NOTES: The 'PolicyID' should not be set when serialize this policy struct to the zset
	// because each 'Policy ID' is different and it may cause issue of losing zset unique capability.
	PolicyID      string                 `json:"policy_id,omitempty"`
	JobName       string                 `json:"job_name"`
	JobParameters map[string]interface{} `json:"job_params"`
	CronSpec      string                 `json:"cron_spec"`
}

PeriodicJobPolicy ...

func (*PeriodicJobPolicy) DeSerialize

func (pjp *PeriodicJobPolicy) DeSerialize(rawJSON []byte) error

DeSerialize the raw json to policy.

func (*PeriodicJobPolicy) Serialize

func (pjp *PeriodicJobPolicy) Serialize() ([]byte, error)

Serialize the policy to raw data.

type RedisPeriodicScheduler

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

RedisPeriodicScheduler manages the periodic scheduling policies.

func NewRedisPeriodicScheduler

func NewRedisPeriodicScheduler(ctx *env.Context, namespace string, redisPool *redis.Pool, statsManager opm.JobStatsManager) *RedisPeriodicScheduler

NewRedisPeriodicScheduler is constructor of RedisPeriodicScheduler

func (*RedisPeriodicScheduler) AcceptPeriodicPolicy

func (rps *RedisPeriodicScheduler) AcceptPeriodicPolicy(policy *PeriodicJobPolicy) error

AcceptPeriodicPolicy is implementation of the same method in period.Interface

func (*RedisPeriodicScheduler) Clear

func (rps *RedisPeriodicScheduler) Clear() error

Clear is implementation of the same method in period.Interface

func (*RedisPeriodicScheduler) Load

func (rps *RedisPeriodicScheduler) Load() error

Load data from zset

func (*RedisPeriodicScheduler) RemovePeriodicPolicy

func (rps *RedisPeriodicScheduler) RemovePeriodicPolicy(policyID string) *PeriodicJobPolicy

RemovePeriodicPolicy is implementation of the same method in period.Interface

func (*RedisPeriodicScheduler) Schedule

func (rps *RedisPeriodicScheduler) Schedule(jobName string, params models.Parameters, cronSpec string) (string, int64, error)

Schedule is implementation of the same method in period.Interface

func (*RedisPeriodicScheduler) Start

func (rps *RedisPeriodicScheduler) Start()

Start to serve

func (*RedisPeriodicScheduler) UnSchedule

func (rps *RedisPeriodicScheduler) UnSchedule(cronJobPolicyID string) error

UnSchedule is implementation of the same method in period.Interface

type Sweeper

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

Sweeper take charge of clearing the outdated data such as scheduled jobs etc.. Currently, only used in redis worker pool.

func NewSweeper

func NewSweeper(namespace string, pool *redis.Pool, client *work.Client) *Sweeper

NewSweeper is constructor of Sweeper.

func (*Sweeper) ClearOutdatedScheduledJobs

func (s *Sweeper) ClearOutdatedScheduledJobs() error

ClearOutdatedScheduledJobs clears the outdated scheduled jobs. Try best to do

Jump to

Keyboard shortcuts

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