Documentation
¶
Overview ¶
Package policy provides tooling for creating and executing Benthos message batch policies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Batcher ¶
type Batcher struct {
// contains filtered or unexported fields
}
Batcher implements a batching policy by buffering messages until, based on a set of rules, the buffered messages are ready to be sent onwards as a batch.
func New ¶
func New(conf batchconfig.Config, mgr bundle.NewManagement) (*Batcher, error)
New creates an empty policy with default rules.
func (*Batcher) Add ¶
Add a new message part to this batch policy. Returns true if this part triggers the conditions of the policy.
func (*Batcher) Count ¶
Count returns the number of currently buffered message parts within this policy.
func (*Batcher) Flush ¶
Flush clears all messages stored by this batch policy and applies any batching processors to them. The returned values distinguish three outcomes:
- (batch, nil): a batch is ready to be sent onwards.
- (nil, nil): the policy is currently empty, or the batching processors intentionally filtered every message away. Callers should treat the buffered transactions as successfully consumed (ack).
- (nil, err): the batching processors failed and the batch has been dropped. Callers should treat the buffered transactions as failed (nack) so the source can retry them, rather than passing unprocessed data on.
Click to show internal directories.
Click to hide internal directories.