Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisBatcher ¶
type RedisBatcher struct {
// contains filtered or unexported fields
}
RedisBatcher provide persistence batching mechanism backed by redis, the persistence is as far as redis definition of persistance
func NewRBatcher ¶
func NewRBatcher(uniqueID string, maxBatch int, redispool *redis.Pool) (batcher *RedisBatcher)
NewRBatcher create redis batcher instance the uniqueness of the id is important to avoid racing condition with other batcher
func (*RedisBatcher) CloseBatch ¶
func (r *RedisBatcher) CloseBatch()
CloseBatch close a batch session
func (*RedisBatcher) Enqueue ¶
func (r *RedisBatcher) Enqueue(element interface{}) (err error)
Enqueue add element to the queue
func (*RedisBatcher) GetBatch ¶
func (r *RedisBatcher) GetBatch() (elements []interface{}, err error)
GetBatch returns elements from the queue as many as maxBatch. This will open a batch session which need to be closed before getting another batch. When the app crash before calling CloseBatch, the elements will be included on the next GetBatch call
Click to show internal directories.
Click to hide internal directories.