cron

package
v0.0.0-...-388d6c9 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package cron implemented the cron trigger and handler convertor.go implements the conversion between entity and po

Package cron implemented the cron trigger and handler entity.go implements the cron template

Package cron implemented the cron trigger and handler handler.go implements the grpc handler of cron trigger

Package cron implemented the cron trigger and handler template.go implements the cron template

Package cron implemented the cron trigger and handler track.go is the cron trigger loop

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	pb.UnimplementedCronTriggerServiceServer
	// contains filtered or unexported fields
}

Handler implements the grpc handler of cron trigger

func NewHandler

func NewHandler(t *Trigger) *Handler

NewHandler returns a new cron trigger handler

func (*Handler) FindOneByID

FindOneByID find one by id

func (*Handler) PageQuery

PageQuery page query

func (*Handler) Register

Register register a webhook trigger template

func (*Handler) UpdateStatus

func (h *Handler) UpdateStatus(ctx context.Context, req *pb.UpdateStatusRequest) (*pb.UpdateStatusResponse, error)

UpdateStatus update the status of trigger

type Trigger

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

Trigger is the cron trigger

func NewTrigger

func NewTrigger(db *mysql.Client, client broker.SchedulerServiceClient) *Trigger

NewTrigger create a new cron trigger

func (*Trigger) FindByID

func (t *Trigger) FindByID(ctx context.Context, id uint) (*TriggerTemplate, error)

FindByID find cron template by id

func (*Trigger) PageQuery

func (t *Trigger) PageQuery(ctx context.Context, p *constants.PageQuery,
	status pb.TriggerStatus) ([]*TriggerTemplate, int64, error)

PageQuery page query cron templates

func (*Trigger) Register

func (t *Trigger) Register(ctx context.Context, temp *TriggerTemplate) error

Register register a cron template

func (*Trigger) Run

func (t *Trigger) Run()

Run run cron trigger loop to produce delay message

func (*Trigger) Tracking

func (t *Trigger) Tracking(temp *po.CronTriggerTemplate) error

Tracking try to produce Cron Trigger Message

func (*Trigger) UpdateStatus

func (t *Trigger) UpdateStatus(ctx context.Context, id uint, status pb.TriggerStatus) (int64, error)

UpdateStatus update cron template status

type TriggerTemplate

type TriggerTemplate struct {
	// ID is the unique identifier of the trigger template.
	ID uint

	// CronExpr is the cron expression.
	CronExpr string `json:"cron_expr" validate:"required"`
	// Topic the message topic
	Topic string `validate:"required"`
	// Payload the message payload
	Payload []byte `validate:"required"`

	// LastExecutionTime last time to schedule the message
	LastExecutionTime time.Time `json:"last_execution_time"`
	// LoopedTimes already loop times
	LoopedTimes uint64 `json:"looped_times"`

	// ExceptedEndTime Excepted Trigger end time, if it is 0, it means that it will not end.
	ExceptedEndTime time.Time `json:"excepted_end_time"`
	// ExceptedLoopTimes except loop times
	ExceptedLoopTimes uint64 `json:"excepted_loop_times"`

	// Status the CronTriggerTemplate status: enable offline
	Status pb.TriggerStatus `json:"status" validate:"required"`
}

TriggerTemplate is the entity of cron trigger template.

Jump to

Keyboard shortcuts

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