Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer[Item any] interface { // Adds the given item to the buffer, even if it would cause the buffer to // exceed its size limit. Returns true if the buffer is at or exceeds its size // limit after this operation, and false otherwise. Add(item Item) (bool, error) // Flushes the buffer to the items' consumer. On return, the buffer will be // empty, even when an error occurs. Flush() error }
Encapsulates a buffer of items and its consumer. The buffer has a soft size limit. Implementations will accept items that cause the buffer to exceed this limit, but clients are expected to call Flush on the buffer when the Add operation reports that the soft limit has been reached.
Implementations do not need to be thread-safe.
type InMemory ¶
type InMemory[Item any] struct { // contains filtered or unexported fields }
A wrapper around a Buffer[Item] that manages thread-safety and flushing.
func NewInMemory ¶
Click to show internal directories.
Click to hide internal directories.