Documentation ¶
Index ¶
- Variables
- type Job
- type Logger
- type Option
- type Queue
- func (q *Queue) Capacity() int
- func (q *Queue) Queue(job QueuedMessage) error
- func (q *Queue) QueueTask(task TaskFunc) error
- func (q *Queue) QueueTaskWithTimeout(timeout time.Duration, task TaskFunc) error
- func (q *Queue) QueueWithTimeout(timeout time.Duration, job QueuedMessage) error
- func (q *Queue) Shutdown()
- func (q *Queue) Start()
- func (q *Queue) Usage() int
- func (q *Queue) Wait()
- func (q *Queue) Workers() int
- type QueuedMessage
- type TaskFunc
- type Worker
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrMissingWorker = errors.New("missing worker module")
ErrMissingWorker missing define worker
View Source
var ErrQueueShutdown = errors.New("queue has been closed and released")
ErrQueueShutdown the queue is released and closed.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct { Task TaskFunc `json:"-"` Timeout time.Duration `json:"timeout"` Body []byte `json:"body"` }
Job with Timeout
type Logger ¶
type Logger interface { Infof(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Info(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) }
Logger interface is used throughout gorush
func NewEmptyLogger ¶
func NewEmptyLogger() Logger
NewEmptyLogger for simple logger.
Example ¶
l := NewEmptyLogger() l.Info("test") l.Infof("test") l.Error("test") l.Errorf("test") l.Fatal("test") l.Fatalf("test")
Output:
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
A Queue is a message queue.
func (*Queue) QueueTaskWithTimeout ¶
QueueTaskWithTimeout to queue job task with timeout
func (*Queue) QueueWithTimeout ¶
func (q *Queue) QueueWithTimeout(timeout time.Duration, job QueuedMessage) error
Queue to queue all job
type Worker ¶
type Worker interface { // BeforeRun is called before starting the worker BeforeRun() error // Run is called to start the worker Run() error // BeforeRun is called after starting the worker AfterRun() error // Shutdown is called if stop all worker Shutdown() error // Queue to send message in Queue (single channel, NSQ or AWS SQS) Queue(job QueuedMessage) error // Capacity queue capacity = cap(channel name) Capacity() int // Usage is how many message in queue Usage() int }
Worker interface
Click to show internal directories.
Click to hide internal directories.