task

package
v0.0.0-...-a6be2c3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Queues map[string]*Queue

	QueueWG sync.WaitGroup

	ExitAfterDone int
)
View Source
var DebugTasksCounter map[string]int
View Source
var RegisteredTasks map[string]job.JobFunc

A list of tasks that I can execute A map of { task-name: JobFunc }

Functions

func AddQueue

func AddQueue(q *Queue)

func Get

func Get(name string) job.JobFunc

func RegisterTask

func RegisterTask(name string, task job.JobFunc)

Task registration may happen before initialization so do not use logger here.

func SetLogger

func SetLogger(logger *zap.Logger)

func StartAllQueues

func StartAllQueues()

Non-blocking function thats runs all queues.

func StopAllQueues

func StopAllQueues()

func Total

func Total() int

Types

type Queue

type Queue = job.Queue

type TasksBroker

type TasksBroker interface {

	// URI, workerID, channelName, Monitor
	Init(string, string, string, bool) error
	Connect() error
	Healthy() bool

	// Delay sends task to a tasks broker.
	// Delay(taskName string, args ...interface{})
	// Returns job's UUID
	Delay(string, ...interface{}) string

	Close()
}
var Broker TasksBroker

type TasksBrokerSTAN

type TasksBrokerSTAN struct {
	URI string
	ID  string

	Monitor bool

	STAN stan.Conn // NATS-streaming
	// contains filtered or unexported fields
}

Tasks broker implementation for NATS-streaming

func (*TasksBrokerSTAN) Close

func (b *TasksBrokerSTAN) Close()

func (*TasksBrokerSTAN) Connect

func (b *TasksBrokerSTAN) Connect() (err error)

func (*TasksBrokerSTAN) Delay

func (b *TasksBrokerSTAN) Delay(taskName string, args ...interface{}) string

Delay sends a message to TasksBroker (puts a task to a queue) Returns job's UUID

func (*TasksBrokerSTAN) Healthy

func (b *TasksBrokerSTAN) Healthy() bool

func (*TasksBrokerSTAN) Init

func (b *TasksBrokerSTAN) Init(URI string, clientID string, channel string, Monitor bool) (err error)

func (*TasksBrokerSTAN) MessageReceived

func (b *TasksBrokerSTAN) MessageReceived(m *stan.Msg)

Message from NATS-streaming received (a new task received)

func (*TasksBrokerSTAN) Subscribe

func (b *TasksBrokerSTAN) Subscribe() (err error)

Jump to

Keyboard shortcuts

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