{"modulePath":"github.com/InVisionApp/benthos","version":"v0.1.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package ring\n\nPackage ring - Defines strategies for generating and managing ring buffers.\n\n## Variables\n\n```go\nvar ErrWrongTrackerLength = errors.New(\"tracker was unexpected length\")\n```\nErrWrongTrackerLength - The length of a read tracker was not correct.\n\n## Types\n\n```go\ntype CachedMmap struct {\n\t// contains filtered or unexported fields\n}\n```\nCachedMmap - A struct containing a cached Mmap file and the file handler.\n\n```go\ntype Memory struct {\n\t// contains filtered or unexported fields\n}\n```\nMemory - A purely memory based ring buffer. This buffer blocks when the buffer is full.\n\n```go\nfunc NewMemory(config MemoryConfig) *Memory\n```\nNewMemory - Creates a new memory based ring buffer.\n\n```go\nfunc (m *Memory) Close()\n```\nClose - Unblocks any blocked calls and prevents further writing to the block.\n\n```go\nfunc (m *Memory) CloseOnceEmpty()\n```\nCloseOnceEmpty - Closes the memory buffer once the backlog reaches 0.\n\n```go\nfunc (m *Memory) NextMessage() (types.Message, error)\n```\nNextMessage - Reads the next message, this call blocks until there's something to read.\n\n```go\nfunc (m *Memory) PushMessage(msg types.Message) (int, error)\n```\nPushMessage - Pushes a new message onto the block, returns the backlog count.\n\n```go\nfunc (m *Memory) ShiftMessage() (int, error)\n```\nShiftMessage - Removes the last message from the block. Returns the backlog count.\n\n```go\ntype MemoryConfig struct {\n\tLimit int `json:\"limit\" yaml:\"limit\"`\n}\n```\nMemoryConfig - Config values for a purely memory based ring buffer type.\n\n```go\nfunc NewMemoryConfig() MemoryConfig\n```\nNewMemoryConfig - Create a new MemoryConfig with default values.\n\n```go\ntype MessageStack interface {\n\t// ShiftMessage - Remove the oldest message from the stack. Returns the backlog in bytes.\n\tShiftMessage() (int, error)\n\n\t// NextMessage - Read the oldest message, the message is preserved until ShiftMessage is called.\n\tNextMessage() (types.Message, error)\n\n\t// PushMessage - Add a new message to the stack. Returns the backlog in bytes.\n\tPushMessage(types.Message) (int, error)\n\n\t// CloseOnceEmpty - Close the MessageStack once the buffer has been emptied, this is a way for a\n\t// writer to signal to a reader that it is finished writing messages, and therefore the reader\n\t// can close once it is caught up. This call blocks until the close is completed.\n\tCloseOnceEmpty()\n\n\t// Close - Close the MessageStack so that blocked readers or writers become unblocked.\n\tClose()\n}\n```\nMessageStack - Represents a method of stacking messages for persistence or fast buffering.\n\n```go\ntype Mmap struct {\n\t// contains filtered or unexported fields\n}\n```\nMmap - A ring buffer implemented around memory mapped files. NOTE: Currently the 'ring' is non existent since files are created as memory is needed. However, we may in future want to limit the space used on disk and therefore looping will need to be implemented.\n\n```go\nfunc NewMmap(config MmapConfig, log log.Modular, stats metrics.Type) (*Mmap, error)\n```\nNewMmap - Creates a block for buffering serialized messages.\n\n```go\nfunc (f *Mmap) Close()\n```\nClose - Unblocks any blocked calls and prevents further writing to the block.\n\n```go\nfunc (f *Mmap) CloseOnceEmpty()\n```\nCloseOnceEmpty - Closes the mmap buffer once the backlog reaches 0.\n\n```go\nfunc (f *Mmap) NextMessage() (types.Message, error)\n```\nNextMessage - Reads the next message, this call blocks until there's something to read.\n\n```go\nfunc (f *Mmap) PushMessage(msg types.Message) (int, error)\n```\nPushMessage - Pushes a new message onto the block, returns the backlog count.\n\n```go\nfunc (f *Mmap) ShiftMessage() (int, error)\n```\nShiftMessage - Removes the last message from the block. Returns the backlog count.\n\n```go\ntype MmapCache struct {\n\t*sync.Cond\n\t// contains filtered or unexported fields\n}\n```\nMmapCache - Keeps track of any Mmap files cached in memory and cleans up resources as they are unclaimed. This type works similarly to sync.Cond, where if you wish to use it you need to lock it.\n\n```go\nfunc NewMmapCache(config MmapCacheConfig) (*MmapCache, error)\n```\nNewMmapCache - Creates a cache for managing open mmap files.\n\n```go\nfunc (f *MmapCache) Delete(index int) error\n```\nDelete - Deletes the file for an index.\n\n```go\nfunc (f *MmapCache) EnsureCached(index int) error\n```\nEnsureCached - Check that a particular index is cached, and if not then read the index, this call blocks until either the index is successfully cached or an error occurs.\n\n```go\nfunc (f *MmapCache) Get(index int) []byte\n```\nGet - Returns the \\[]byte from a memory mapped file index.\n\n```go\nfunc (f *MmapCache) GetTracker() []byte\n```\nGetTracker - Returns the \\[]byte from the tracker file memory mapping.\n\n```go\nfunc (f *MmapCache) IsCached(index int) bool\n```\nIsCached - Returns a bool indicating whether the current memory mapped file index is cached.\n\n```go\nfunc (f *MmapCache) Remove(index int) error\n```\nRemove - Removes the index from our cache, the file is NOT deleted.\n\n```go\nfunc (f *MmapCache) RemoveAll() error\n```\nRemoveAll - Removes all indexes from the cache as well as the tracker.\n\n```go\ntype MmapCacheConfig struct {\n\tPath          string `json:\"directory\" yaml:\"directory\"`\n\tFileSize      int    `json:\"file_size\" yaml:\"file_size\"`\n\tRetryPeriodMS int    `json:\"retry_period_ms\" yaml:\"retry_period_ms\"`\n\tCleanUp       bool   `json:\"clean_up\" yaml:\"clean_up\"`\n}\n```\nMmapCacheConfig - Config options for the MmapCache type.\n\n```go\nfunc NewMmapCacheConfig() MmapCacheConfig\n```\nNewMmapCacheConfig - Creates a new MmapCacheConfig oject with default values.\n\n```go\ntype MmapConfig MmapCacheConfig\n```\nMmapConfig - Config options for a memory-map based ring buffer.\n\n```go\nfunc NewMmapConfig() MmapConfig\n```\nNewMmapConfig - Creates a new MmapConfig oject with default values.\n\n","path":"github.com/InVisionApp/benthos/lib/buffer/ring","name":"ring","synopsis":"Package ring - Defines strategies for generating and managing ring buffers.","isRedistributable":true}
