Documentation
¶
Index ¶
- type Factory
- type FailureStrategy
- type FileFactoryOption
- func WithFailureStrategy(s FailureStrategy) FileFactoryOption
- func WithFlushBatchMaxBytes(bytes int64) FileFactoryOption
- func WithFlushBatchSize(n int) FileFactoryOption
- func WithFlushInterval(interval time.Duration) FileFactoryOption
- func WithFlushOnClose(enabled bool) FileFactoryOption
- func WithMaxActiveSize(bytes int64) FileFactoryOption
- func WithMaxAppendsBeforeFlush(n int) FileFactoryOption
- func WithMaxBytesBeforeFlush(bytes int64) FileFactoryOption
- func WithMaxFailures(n int) FileFactoryOption
- func WithNowFunc(fn func() time.Time) FileFactoryOption
- type FlushHandler
- type Spool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory interface {
Create(handler FlushHandler) (Spool, error)
Close() error
}
Factory creates and manages spool lifecycle.
func NewFileFactory ¶
NewFileFactory creates a file-backed spool factory.
type FailureStrategy ¶
FailureStrategy defines the action to take when an inflight spool file exceeds the maximum number of consecutive flush failures.
func NewDeleteStrategy ¶
func NewDeleteStrategy() FailureStrategy
NewDeleteStrategy creates a FailureStrategy that deletes inflight files when consecutive flush failures exceed the threshold.
func NewQuarantineStrategy ¶
func NewQuarantineStrategy() FailureStrategy
NewQuarantineStrategy creates a FailureStrategy that quarantines inflight files by renaming them with a .quarantine suffix when consecutive flush failures exceed the threshold.
type FileFactoryOption ¶
type FileFactoryOption func(*fileFactory)
FileFactoryOption configures a fileFactory.
func WithFailureStrategy ¶
func WithFailureStrategy(s FailureStrategy) FileFactoryOption
WithFailureStrategy sets the strategy invoked when an inflight file exceeds the maximum number of consecutive flush failures. When nil (the default), inflight files are deleted on threshold breach.
func WithFlushBatchMaxBytes ¶
func WithFlushBatchMaxBytes(bytes int64) FileFactoryOption
WithFlushBatchMaxBytes sets the maximum payload bytes returned per call to the next function passed to the Flush callback. Zero disables the limit.
func WithFlushBatchSize ¶
func WithFlushBatchSize(n int) FileFactoryOption
WithFlushBatchSize sets the maximum number of frames returned per call to the next function passed to the Flush callback. Zero disables batching, causing all frames in the inflight file to be returned in a single batch.
func WithFlushInterval ¶
func WithFlushInterval(interval time.Duration) FileFactoryOption
WithFlushInterval sets periodic flush interval. Zero disables the timer.
func WithFlushOnClose ¶
func WithFlushOnClose(enabled bool) FileFactoryOption
WithFlushOnClose enables final flush during Close. Default is true.
func WithMaxActiveSize ¶
func WithMaxActiveSize(bytes int64) FileFactoryOption
WithMaxActiveSize sets the maximum size (in bytes) for an active spool file. When an Append would cause the active file to exceed this limit, the current active file is rotated to a sealed inflight file and a fresh active file is started. Zero (default) means no size limit.
func WithMaxAppendsBeforeFlush ¶
func WithMaxAppendsBeforeFlush(n int) FileFactoryOption
WithMaxAppendsBeforeFlush triggers flush after this many append calls. Zero disables this trigger.
func WithMaxBytesBeforeFlush ¶
func WithMaxBytesBeforeFlush(bytes int64) FileFactoryOption
WithMaxBytesBeforeFlush triggers flush after this many appended bytes. Zero disables this trigger.
func WithMaxFailures ¶
func WithMaxFailures(n int) FileFactoryOption
WithMaxFailures sets the per-key consecutive failure threshold before the failure strategy is invoked. Default is 20.
func WithNowFunc ¶
func WithNowFunc(fn func() time.Time) FileFactoryOption
WithNowFunc overrides the clock used to generate inflight timestamps. Intended for testing.
type FlushHandler ¶
FlushHandler is called during flush cycles for each inflight file.