{"modulePath":"github.com/windhooked/benthos","version":"v0.26.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package parallel\n\nPackage parallel contains implementations of various buffer types where the buffer can be consumed by any number of parallel consumer threads. Therefore, since it is possible for consumers to requeue a message if the propagation failed, it is possible for messages to be consumed out of sequence.\n\n## Types\n\n```go\ntype AckFunc func(ack bool) (int, error)\n```\nAckFunc is a func returned when a message is read from a parallel buffer. The func should be called when the message is finished with, and a flag indicates whether the message was successfully propagated and can be removed from the buffer. Returns the current backlog of the buffer in bytes, or an error if the message was not successfully removed.\n\nIf an error is returned it is safe to call the function again. Otherwise, it is not.\n\nIt is safe to call this func even if the buffer has closed.\n\n```go\ntype Memory struct {\n\t// contains filtered or unexported fields\n}\n```\nMemory is a parallel buffer implementation that allows multiple parallel consumers to read and purge messages from the buffer asynchronously.\n\n```go\nfunc NewMemory(cap int) *Memory\n```\nNewMemory creates a memory based parallel buffer.\n\n```go\nfunc (m *Memory) Close()\n```\nClose closes the Buffer so that blocked readers or writers become unblocked.\n\n```go\nfunc (m *Memory) CloseOnceEmpty()\n```\nCloseOnceEmpty closes the Buffer once the buffer has been emptied, this is a way for a writer to signal to a reader that it is finished writing messages, and therefore the reader can close once it is caught up. This call blocks until the close is completed.\n\n```go\nfunc (m *Memory) NextMessage() (types.Message, AckFunc, error)\n```\nNextMessage reads the next oldest message, the message is preserved until the returned AckFunc is called.\n\n```go\nfunc (m *Memory) PushMessage(msg types.Message) (int, error)\n```\nPushMessage adds a new message to the stack. Returns the backlog in bytes.\n\n","path":"github.com/windhooked/benthos/lib/buffer/parallel","name":"parallel","synopsis":"Package parallel contains implementations of various buffer types where the buffer can be consumed by any number of parallel consumer threads.","isRedistributable":true}
