Documentation
¶
Index ¶
- Variables
- type Logger
- type Metric
- type Option
- type OptionFunc
- type Options
- type Queue
- func (q *Queue) AddWorker(size int, opts ...Option) *Queue
- func (q *Queue) BusyWorkers() int
- func (q *Queue) FailureTasks() int
- func (q *Queue) Queue(ctx context.Context, message core.QueuedMessage, opts ...job.AllowOption) error
- func (q *Queue) QueueTask(task job.TaskFunc, opts ...job.AllowOption) error
- func (q *Queue) Release()
- func (q *Queue) Shutdown()
- func (q *Queue) Start()
- func (q *Queue) SubmittedTasks() int
- func (q *Queue) SuccessTasks() int
- func (q *Queue) UpdateWorkerCount(num int)
- func (q *Queue) Wait()
- type Ring
- func (s *Ring) Queue(ctx context.Context, task core.QueuedMessage) error
- func (s *Ring) QueueAsync(ctx context.Context, task core.QueuedMessage) error
- func (s *Ring) Request() (core.QueuedMessage, error)
- func (s *Ring) Run(ctx context.Context, task core.QueuedMessage) error
- func (s *Ring) Shutdown() error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoTaskInQueue there is nothing in the queue ErrNoTaskInQueue = errors.New("golang-queue: no task in queue") // ErrQueueHasBeenClosed the current queue is closed ErrQueueHasBeenClosed = errors.New("golang-queue: queue has been closed") // ErrMaxCapacity Maximum size limit reached ErrMaxCapacity = errors.New("golang-queue: maximum size limit reached") )
var ErrMissingWorker = errors.New("missing worker module")
ErrMissingWorker missing define worker
var ErrQueueShutdown = errors.New("queue has been closed and released")
ErrQueueShutdown the queue is released and closed.
Functions ¶
This section is empty.
Types ¶
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")
type Metric ¶
type Metric interface {
IncBusyWorker()
DecBusyWorker()
BusyWorkers() uint64
SuccessTasks() uint64
FailureTasks() uint64
SubmittedTasks() uint64
IncSuccessTask()
IncFailureTask()
IncSubmittedTask()
}
Metric interface
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
An Option configures a mutex.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options for custom args in Queue
func NewOptions ¶
NewOptions initialize the default value for the options
type Queue ¶
A Queue is a message queue.
func (*Queue) BusyWorkers ¶
BusyWorkers returns the numbers of workers in the running process.
func (*Queue) FailureTasks ¶
BusyWorkers returns the numbers of failure tasks.
func (*Queue) Queue ¶
func (q *Queue) Queue(ctx context.Context, message core.QueuedMessage, opts ...job.AllowOption) error
Queue to queue single job with binary
func (*Queue) SubmittedTasks ¶
BusyWorkers returns the numbers of submitted tasks.
func (*Queue) SuccessTasks ¶
BusyWorkers returns the numbers of success tasks.
func (*Queue) UpdateWorkerCount ¶
UpdateWorkerCount to update worker number dynamically.
type Ring ¶
Ring for simple queue using buffer channel
func (*Ring) QueueAsync ¶
QueueAsync send task to the buffer channel
func (*Ring) Request ¶
func (s *Ring) Request() (core.QueuedMessage, error)
Request a new task from channel