core

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimestampMode = iota
	CronMode
)

Variables

View Source
var ErrMaxEventQueueCapacity = errors.New("the max eventQueue capacity has been reached")
View Source
var ErrMaxRawEventQueueCapacity = errors.New("the max rawEventQueue capacity has been reached")
View Source
var ErrMaxStackCapacity = errors.New("the max stack capacity has been reached")
View Source
var (
	ErrNotFound = errors.New("the requested item cannot be found")
)
View Source
var (
	ErrNotImplemented = errors.New("this method is not implemented")
)

Functions

This section is empty.

Types

type CacheManager

type CacheManager interface {
	PersistenceManager
}

func NewRedisCacheManager

func NewRedisCacheManager(conf RedisCacheManagerConfig) (CacheManager, error)

type DispatchFunc

type DispatchFunc func(Event) error

type DispatchManagerConfig

type DispatchManagerConfig struct {
	WorkerNumber         int
	DefaultQueueCapacity int
	MaxQueueCapacity     int
}

type Event

type Event struct {
	ID ID

	// CronExpression allows us to schedule the event based on the cron expression
	CronExpression string

	// ShouldExecuteAt is the timestamp at which the event must be scheduled
	ShouldExecuteAt time.Time

	// Mode is the mode in which the event should be scheduled (CronMode or TimestampMode)
	Mode EventMode

	// Topic is the channel on which the event has to be dispatched
	Topic string

	// Payload is the content of the event
	Payload []byte
}

type EventMode

type EventMode uint

type ID

type ID string

type PersistenceManager

type PersistenceManager interface {
	Add(ctx context.Context, e Event) error
	AddBulk(ctx context.Context, evs []Event) error
	Delete(ctx context.Context, id ID) error
	Get(ctx context.Context, id ID) (Event, error)
	GetAll(ctx context.Context) ([]Event, error)
}

type RedisCacheManagerConfig

type RedisCacheManagerConfig struct {
	Addr string
	Pass string
	DB   int
}

type Scheduler

type Scheduler interface {
	Schedule(e Event) (ID, error)
	Unschedule(id ID) error

	Start() error
	Stop()
	SetConfig(conf SchedulerConfig) error
	// contains filtered or unexported methods
}

type SchedulerConfig

type SchedulerConfig struct {
	StackManagerConfig
	DispatchManagerConfig
	DefaultInputQueueCapacity int
	MaxInputQueueCapacity     int
	MaxBulkLimit              int
}

type SqlPersistenceManagerConfig

type SqlPersistenceManagerConfig struct {
	Url    string
	Driver string
}

type StackManagerConfig

type StackManagerConfig struct {
	StacksNumber         int
	DefaultStackCapacity int
	MaxStackCapacity     int
}

Jump to

Keyboard shortcuts

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