cronqueue

package
v0.0.0-...-c7c8722 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultExecuteCount = 10

DefaultExecuteCount default execute count

View Source
var DefaultInterval = time.Minute

DefaultInterval default queue interval

View Source
var DefaultTimeout = time.Minute

DefaultTimeout default push timeout

Functions

This section is empty.

Types

type Config

type Config struct {
	TimeoutDuration  string
	IntervalDuration string
	ExecuteCount     int
}

func (*Config) CreateQueue

func (c *Config) CreateQueue() (*Queue, error)

type Engine

type Engine interface {
	//List list queued Execution form start
	List(start string, count int) ([]*notificationqueue.Execution, string, error)
	//Insert insert execution to queue.
	//Do nothing if notifiaction exsits
	Insert(execution *notificationqueue.Execution) error
	//Replace exectution in queue with given eid.
	//Do nothing if eid not match.
	Replace(eid string, new *notificationqueue.Execution) error
	//Remove notifcation with given nid form queue.
	//Do nothing if notificatio not found
	Remove(nid string) error
	//Start start store
	Start() error
	//Stop stop store
	Stop() error
}

Engine queue Engine interface

type PlainRetry

type PlainRetry []string

PlainRetry plain retry config

func (*PlainRetry) CreateRetryHandler

func (r *PlainRetry) CreateRetryHandler() (*PlainRetryHandler, error)

CreateRetryHandler create retry hanlder

type PlainRetryHandler

type PlainRetryHandler []time.Duration

PlainRetryHandler plain retry handler

func (*PlainRetryHandler) HandleRetry

func (h *PlainRetryHandler) HandleRetry(e *notificationqueue.Execution) (bool, error)

HandleRetry execution update retry count,start time,retry after time. Return false if retry too many.

type Queue

type Queue struct {
	Engine       Engine
	Timeout      time.Duration
	Interval     time.Duration
	ExecuteCount int
	IDGenerator  func() (string, error)

	Recover     func()
	OnExecution func(*notificationqueue.Execution)

	RetryHandler RetryHandler
	// contains filtered or unexported fields
}

Queue queue struct

func New

func New() *Queue

New create new queue

func (*Queue) AttachTo

func (q *Queue) AttachTo(n *notificationqueue.Notifier) error

AttachTo attach queue to notifier

func (*Queue) Detach

func (q *Queue) Detach() error

Detach detach queue.

func (*Queue) PopChan

func (q *Queue) PopChan() (<-chan *notificationqueue.Execution, error)

PopChan return execution chan

func (*Queue) Push

func (q *Queue) Push(n *notification.Notification) error

Push push notification to queue

func (*Queue) Remove

func (q *Queue) Remove(nid string) error

Remove remove notification by given id

func (*Queue) Start

func (q *Queue) Start() error

Start start queue

func (*Queue) Stop

func (q *Queue) Stop() error

Stop stop queue

type RetryHandler

type RetryHandler interface {
	//HandleRetry execution update retry count,start time,retry after time.
	//Return false if retry too many.
	HandleRetry(*notificationqueue.Execution) (bool, error)
}

RetryHandler queue retry handler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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