{"modulePath":"github.com/InVisionApp/benthos","version":"v0.9.12","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package impl\n\nPackage impl contains implementations of various buffer types.\n\n## Variables\n\n```go\nvar (\n\t// ErrWrongTrackerLength means the length of a read tracker was not correct.\n\tErrWrongTrackerLength = errors.New(\"tracker was unexpected length\")\n\n\t// ErrNotEnoughSpace means the target disk lacked the space needed for a new\n\t// file.\n\tErrNotEnoughSpace = errors.New(\"target disk is at capacity\")\n)\n```\n\n## Types\n\n```go\ntype Buffer interface {\n\t// ShiftMessage removes the oldest message from the stack. Returns the\n\t// backlog in bytes.\n\tShiftMessage() (int, error)\n\n\t// NextMessage reads the oldest message, the message is preserved until\n\t// ShiftMessage is called.\n\tNextMessage() (types.Message, error)\n\n\t// PushMessage adds a new message to the stack. Returns the backlog in\n\t// bytes.\n\tPushMessage(types.Message) (int, error)\n\n\t// CloseOnceEmpty closes the Buffer once the buffer has been emptied, this\n\t// is a way for a writer to signal to a reader that it is finished writing\n\t// messages, and therefore the reader can close once it is caught up. This\n\t// call blocks until the close is completed.\n\tCloseOnceEmpty()\n\n\t// Close closes the Buffer so that blocked readers or writers become\n\t// unblocked.\n\tClose()\n}\n```\nBuffer represents a method of storing messages.\n\n```go\ntype CachedMmap struct {\n\t// contains filtered or unexported fields\n}\n```\nCachedMmap is 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 is 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 is config values for a purely memory based ring buffer type.\n\n```go\nfunc NewMemoryConfig() MemoryConfig\n```\nNewMemoryConfig creates a new MemoryConfig with default values.\n\n```go\ntype MmapBuffer struct {\n\t// contains filtered or unexported fields\n}\n```\nMmapBuffer is a buffer implemented around rotated memory mapped files.\n\n```go\nfunc NewMmapBuffer(config MmapBufferConfig, log log.Modular, stats metrics.Type) (*MmapBuffer, error)\n```\nNewMmapBuffer creates a memory-map based buffer.\n\n```go\nfunc (f *MmapBuffer) Close()\n```\nClose unblocks any blocked calls and prevents further writing to the block.\n\n```go\nfunc (f *MmapBuffer) CloseOnceEmpty()\n```\nCloseOnceEmpty closes the mmap buffer once the backlog reaches 0.\n\n```go\nfunc (f *MmapBuffer) NextMessage() (types.Message, error)\n```\nNextMessage reads the next message, blocks until there's something to read.\n\n```go\nfunc (f *MmapBuffer) PushMessage(msg types.Message) (int, error)\n```\nPushMessage pushes a new message, returns the backlog count.\n\n```go\nfunc (f *MmapBuffer) ShiftMessage() (int, error)\n```\nShiftMessage removes the last message. Returns the backlog count.\n\n```go\ntype MmapBufferConfig MmapCacheConfig\n```\nMmapBufferConfig is config options for a memory-map based buffer reader.\n\n```go\nfunc NewMmapBufferConfig() MmapBufferConfig\n```\nNewMmapBufferConfig creates a MmapBufferConfig oject with default values.\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, log log.Modular, stats metrics.Type) (*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 checks 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\tReservedDiskSpace uint64 `json:\"reserved_disk_space\" yaml:\"reserved_disk_space\"`\n}\n```\nMmapCacheConfig is config options for the MmapCache type.\n\n```go\nfunc NewMmapCacheConfig() MmapCacheConfig\n```\nNewMmapCacheConfig creates a new MmapCacheConfig oject with default values.\n\n","path":"github.com/InVisionApp/benthos/lib/buffer/impl","name":"impl","synopsis":"Package impl contains implementations of various buffer types.","isRedistributable":true}
