smp

package module
v0.0.0-...-3c0c4c8 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 12 Imported by: 0

README

Rumors scheduler mongo provider plugin

License

Installation

go get github.com/rumorsflow/scheduler-mongo-provider

License

Distributed under MIT License, please see license file within the code for more details.

Documentation

Index

Constants

View Source
const PluginName = "scheduler_mongo_provider"

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option struct {
	Type  OptionType `json:"type" bson:"type"`
	Value string     `json:"value" bson:"value"`
}

type OptionType

type OptionType string
const (
	MaxRetryOpt  OptionType = "max-retry"
	QueueOpt     OptionType = "queue"
	TimeoutOpt   OptionType = "timeout"
	DeadlineOpt  OptionType = "deadline"
	UniqueOpt    OptionType = "unique"
	ProcessAtOpt OptionType = "process-at"
	ProcessInOpt OptionType = "process-in"
	TaskIdOpt    OptionType = "task-id"
	RetentionOpt OptionType = "retention"
	GroupOpt     OptionType = "group"
)

type PeriodicTask

type PeriodicTask struct {
	Id        string    `json:"id,omitempty" bson:"_id"`
	CronExpr  string    `json:"cron_expr,omitempty" bson:"cron_expr,omitempty"`
	JobCode   string    `json:"job_code,omitempty" bson:"job_code,omitempty"`
	Payload   *string   `json:"payload,omitempty" bson:"payload,omitempty"`
	Opts      *[]Option `json:"opts,omitempty" bson:"opts,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty" bson:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty" bson:"updated_at,omitempty"`
	Enabled   *bool     `json:"enabled,omitempty" bson:"enabled,omitempty"`
}

func (*PeriodicTask) Active

func (pt *PeriodicTask) Active() bool

func (*PeriodicTask) HasOpts

func (pt *PeriodicTask) HasOpts() bool

func (*PeriodicTask) Options

func (pt *PeriodicTask) Options() []asynq.Option

func (*PeriodicTask) SetEnabled

func (pt *PeriodicTask) SetEnabled(enabled bool) *PeriodicTask

func (*PeriodicTask) SetOpts

func (pt *PeriodicTask) SetOpts(opts []Option) *PeriodicTask

func (*PeriodicTask) SetPayload

func (pt *PeriodicTask) SetPayload(payload string) *PeriodicTask

func (*PeriodicTask) Task

func (pt *PeriodicTask) Task() *asynq.Task

type PeriodicTaskStorage

type PeriodicTaskStorage interface {
	Find(ctx context.Context, criteria mongoext.Criteria) ([]PeriodicTask, error)
	Count(ctx context.Context, filter any) (int64, error)
	FindById(ctx context.Context, id string) (PeriodicTask, error)
	Save(ctx context.Context, model *PeriodicTask) error
	Delete(ctx context.Context, id string) error
}

type Plugin

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

func (*Plugin) Init

func (p *Plugin) Init(log *zap.Logger, db *mongo.Database) error

func (*Plugin) Name

func (p *Plugin) Name() string

Name returns user-friendly plugin name

func (*Plugin) PeriodicTaskProvider

func (p *Plugin) PeriodicTaskProvider() asynq.PeriodicTaskConfigProvider

func (*Plugin) Provides

func (p *Plugin) Provides() []any

Provides declares factory methods.

func (*Plugin) Serve

func (p *Plugin) Serve() chan error

func (*Plugin) Stop

func (p *Plugin) Stop() error

func (*Plugin) Storage

func (p *Plugin) Storage() PeriodicTaskStorage

Jump to

Keyboard shortcuts

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