Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrClosed = fmt.Errorf("queue was closed")
Functions ¶
This section is empty.
Types ¶
type Operation ¶
type Operation interface {
UserID() string
}
Operation is an operation, that can be added to the oqueue.
type OperationConsumer ¶
OperationConsumer is a function, that consumes an operation. The consumer might return an error.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue implements an operation queue.
func (*Queue) AddOperation ¶
AddOperation adds an operation to the queue. Returns ErrClosed if the queue was closed.
func (*Queue) AddSubscriber ¶
func (q *Queue) AddSubscriber(consume OperationConsumer, worker int)
type Service ¶
type Service interface { // AddOperation adds an operation to the queue. // It might return an error, if the queue is closed. AddOperation(op Operation) error // AddSubscriber adds an operation consumer. It gets notified for every // operation landing in the queue. // If the consumer returns an error, the error gets logged. // The amount of worker defines how many operations are to be consumed // concurrently. AddSubscriber(consume OperationConsumer, worker int) // Close closes the queue. When closed the queue no longer accepts // operations. // It waits for all operations to be processed before returning. Close() }
Service defines an interface for handling an operator queue. It has methods to add and consume operations. All methods should be save for concurrent use. -go:generate go run github.com/petergtz/pegomock/pegomock generate eintopf.info/service/oqueue Service --output=../../internal/mock/oqueue_service.go --package=mock --mock-name=OQueueService
Click to show internal directories.
Click to hide internal directories.