scheduler

package
v0.0.0-...-8cc84bd Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QueueLock

type QueueLock interface {
	// LockOrPush tries to lock lockID and pushes item to queue by lockID if fails.
	// Return true if locks or false if error or item is added to queue.
	LockOrPush(lockID string, item []byte) (bool, error)
	// LockMultipleOrPush tries to lock all lockIDList
	// and pushes item to queue by lockID if fails.
	LockMultipleOrPush(lockIDList []string, lockID string, item []byte) (bool, error)
	// PopOrUnlock tries to extend lock lockID and pops item from queue by lockID.
	// It unlocks lockID if either fails.
	PopOrUnlock(lockID string) ([]byte, error)
	// LockAndPop tries to lock lockID and pops item from queue by lockID.
	LockAndPop(lockID string) ([]byte, error)
	// IsLocked returns true if lock lockID is set.
	IsLocked(lockID string) bool
	// IsEmpty returns true if queue lockID is empty.
	IsEmpty(lockID string) bool
}

QueueLock interface is used to implement a lock to consistently process items for the same resource. Base implementation uses redis to set lock and store next items while current item is processing. Im-memory mutex is used to synchronize access to redis so it cannot be used in multi-instance app.

func NewQueueLock

func NewQueueLock(
	lockClient redismod.Cmdable,
	lockExpirationTime time.Duration,
	queueClient redismod.Cmdable,
	logger zerolog.Logger,
) QueueLock

NewQueueLock creates lock.

type Scheduler

type Scheduler interface {
	Start()
	Stop()
	ProcessEvent(*amqp.Channel, string, []byte) error
	AckEvent(*amqp.Channel, types.Event) error
}

Scheduler ...

func NewSchedulerService

func NewSchedulerService(
	redisLockStorage *redismod.Client,
	redisQueueStorage *redismod.Client,
	channelPub *amqp.Channel,
	publishToQueue string,
	logger zerolog.Logger,
	lockTtl int,
	alarmService alarm.Service,
	jsonEncoder encoding.Encoder,
	jsonDecoder encoding.Decoder,
	enableMetaAlarmProcessing bool,
) Scheduler

NewSchedulerService ...

Jump to

Keyboard shortcuts

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