boxer

package
v0.0.0-...-757f723 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoSuchIntervalError = errors.New("no such interval")
	NoSuchScopeError    = errors.New("no such scope")
)
View Source
var (
	ErrShutdown = errors.New("buffer is shut down")
	WriteError  = errors.New("error writing to buffer")
)
View Source
var (
	MaintainNotNeeded = errors.New("maintain not needed")
)

Functions

func SafeFilename

func SafeFilename(kind component.Kind, ent component.ID, name string) string

Types

type Boxer

type Boxer struct {
	// contains filtered or unexported fields
}

func BoxerFor

func BoxerFor(path string, kind component.Kind, ent component.ID, name string, boxerOpts ...BoxerOptions) (*Boxer, error)

func NewBoxer

func NewBoxer(options ...BoxerOptions) (*Boxer, error)

func (*Boxer) Close

func (b *Boxer) Close() error

func (*Boxer) CloseInterval

func (b *Boxer) CloseInterval(interval int64) error

func (*Boxer) CloseIntervalScope

func (b *Boxer) CloseIntervalScope(interval int64, scope string) error

func (*Boxer) ForEach

func (b *Boxer) ForEach(interval int64, scope string, fn BoxerForEachFunc) error

func (*Boxer) GetAllIntervals

func (b *Boxer) GetAllIntervals() ([]int64, error)

func (*Boxer) GetClosedIntervals

func (b *Boxer) GetClosedIntervals(ts time.Time) ([]int64, error)

func (*Boxer) GetScopesForInterval

func (b *Boxer) GetScopesForInterval(interval int64) ([]string, error)

func (*Boxer) IntervalForTime

func (b *Boxer) IntervalForTime(ts time.Time) int64

func (*Boxer) Put

func (b *Boxer) Put(scope string, ts time.Time, item []byte) (tooold bool, err error)

Put puts a new item into the timebox. If the item's time is too old, it will not be added, and a nil will be returned.

func (*Boxer) TimeForInterval

func (b *Boxer) TimeForInterval(interval int64) time.Time

type BoxerForEachFunc

type BoxerForEachFunc func(index, expected int, value []byte) (bool, error)

type BoxerOptions

type BoxerOptions interface {
	// contains filtered or unexported methods
}

func WithBufferStorage

func WithBufferStorage(buffer Buffer) BoxerOptions

func WithGrace

func WithGrace(grace time.Duration) BoxerOptions

func WithInterval

func WithInterval(interval time.Duration) BoxerOptions

func WithIntervalCount

func WithIntervalCount(intervalCount int64) BoxerOptions

func WithTimeFunc

func WithTimeFunc(timefunc TimeFunc) BoxerOptions

type Buffer

type Buffer interface {
	Write(data *BufferRecord) error
	GetScopes(interval int64) (scopes []string, err error)
	GetIntervals() (intervals []int64, err error)
	ForEach(interval int64, scope string, f ForEachFunc) error
	CloseIntervalScope(interval int64, scope string) error
	CloseInterval(interval int64) error
	Shutdown() error
}

type BufferRecord

type BufferRecord struct {
	Scope    string
	Interval int64
	Contents []byte
}

type FileItem

type FileItem struct {
	// contains filtered or unexported fields
}

type FilesystemBuffer

type FilesystemBuffer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewFilesystemBuffer

func NewFilesystemBuffer(directory string) *FilesystemBuffer

func (*FilesystemBuffer) CloseInterval

func (b *FilesystemBuffer) CloseInterval(interval int64) error

func (*FilesystemBuffer) CloseIntervalScope

func (b *FilesystemBuffer) CloseIntervalScope(interval int64, scope string) error

func (*FilesystemBuffer) ForEach

func (b *FilesystemBuffer) ForEach(interval int64, scope string, fn ForEachFunc) error

func (*FilesystemBuffer) GetIntervals

func (b *FilesystemBuffer) GetIntervals() (intervals []int64, err error)

func (*FilesystemBuffer) GetScopes

func (b *FilesystemBuffer) GetScopes(interval int64) (scopes []string, err error)

func (*FilesystemBuffer) Shutdown

func (b *FilesystemBuffer) Shutdown() error

func (*FilesystemBuffer) Write

func (b *FilesystemBuffer) Write(data *BufferRecord) error

type ForEachFunc

type ForEachFunc func(index, expected int, record *BufferRecord) (keepGoing bool, err error)

type MemoryBuffer

type MemoryBuffer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewMemoryBuffer

func NewMemoryBuffer() *MemoryBuffer

func (*MemoryBuffer) CloseInterval

func (b *MemoryBuffer) CloseInterval(interval int64) error

func (*MemoryBuffer) CloseIntervalScope

func (b *MemoryBuffer) CloseIntervalScope(interval int64, scope string) error

func (*MemoryBuffer) ForEach

func (b *MemoryBuffer) ForEach(interval int64, scope string, fn ForEachFunc) error

func (*MemoryBuffer) GetIntervals

func (b *MemoryBuffer) GetIntervals() (intervals []int64, err error)

func (*MemoryBuffer) GetScopes

func (b *MemoryBuffer) GetScopes(interval int64) (scopes []string, err error)

func (*MemoryBuffer) Shutdown

func (b *MemoryBuffer) Shutdown() error

func (*MemoryBuffer) Wipe

func (b *MemoryBuffer) Wipe() error

func (*MemoryBuffer) Write

func (b *MemoryBuffer) Write(data *BufferRecord) error

type MemoryItem

type MemoryItem struct {
	// contains filtered or unexported fields
}

type TimeFunc

type TimeFunc func() time.Time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL