storage

package
v0.0.0-...-6e93ffc Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Afero

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

func NewAfero

func NewAfero(fs afero.Fs, path string, mode Mode, perm os.FileMode) *Afero

func (Afero) GetMode

func (s Afero) GetMode() Mode

func (Afero) GetShard

func (s Afero) GetShard(ts time.Time) (Shard, error)

func (Afero) GetShards

func (s Afero) GetShards() ([]Shard, error)

func (Afero) GetShardsRange

func (s Afero) GetShardsRange(from time.Time, to time.Time) ([]Shard, error)

type AferoShard

type AferoShard struct {
	FileShard
	// contains filtered or unexported fields
}

func (AferoShard) Add

func (s AferoShard) Add(records []Record) (int, error)

func (AferoShard) GetAllCallback

func (s AferoShard) GetAllCallback(callback QueryCallback) error

func (AferoShard) GetDate

func (s AferoShard) GetDate() time.Time

type File

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

func NewFile

func NewFile(path string, mode Mode, perm os.FileMode) *File

func (File) GetMode

func (s File) GetMode() Mode

func (File) GetShard

func (s File) GetShard(ts time.Time) (Shard, error)

func (File) GetShards

func (s File) GetShards() ([]Shard, error)

func (File) GetShardsRange

func (s File) GetShardsRange(from time.Time, to time.Time) ([]Shard, error)

type FileShard

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

func (FileShard) Add

func (s FileShard) Add(records []Record) (int, error)

func (FileShard) GetAllCallback

func (s FileShard) GetAllCallback(callback QueryCallback) error

func (FileShard) GetDate

func (s FileShard) GetDate() time.Time

type Memory

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

Memory implements the QuartzDBStorage client interface in memory useful for testing as the data is not persisted

func NewMemory

func NewMemory(mode Mode) *Memory

NewMemory creates new memory client

func (Memory) GetMode

func (s Memory) GetMode() Mode

func (*Memory) GetShard

func (s *Memory) GetShard(ts time.Time) (Shard, error)

func (*Memory) GetShards

func (s *Memory) GetShards() ([]Shard, error)

func (*Memory) GetShardsRange

func (s *Memory) GetShardsRange(from time.Time, to time.Time) ([]Shard, error)

type MemoryShard

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

MemoryShard implements the Shard interface for the Memory storage

func (*MemoryShard) Add

func (s *MemoryShard) Add(records []Record) (int, error)

func (MemoryShard) GetAllCallback

func (s MemoryShard) GetAllCallback(callback QueryCallback) error

func (MemoryShard) GetDate

func (s MemoryShard) GetDate() time.Time

type Mode

type Mode rune

Mode determines the client data access mode read/read-write

const (
	// ModeRead opens the database in read only mode
	ModeRead Mode = 'r'
	// ModeWrite opens the database in read-write mode
	ModeWrite Mode = 'w'
)

type QuartzDBStorage

type QuartzDBStorage interface {
	GetMode() Mode
	GetShard(ts time.Time) (Shard, error)
	GetShards() ([]Shard, error)
	GetShardsRange(from time.Time, to time.Time) ([]Shard, error)
}

QuartzDBStorage is a QuartzDB storage interface

type QueryCallback

type QueryCallback = func(record Record) (stop bool, err error)

QueryCallback is a callback function function used to iterate over records

type RawRecord

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

RawRecord implements Record which can contain any raw bytes data

func NewRawRecord

func NewRawRecord(ts time.Time, bytes []byte) RawRecord

NewRawRecord creates new RawRecord

func (RawRecord) Bytes

func (mr RawRecord) Bytes() []byte

Bytes returns the record content

func (RawRecord) Time

func (mr RawRecord) Time() time.Time

Time returns the record time

type Record

type Record interface {
	Time() time.Time
	Bytes() []byte
}

Record is an interface for single record item. Every record must be timestamped and serializeabe to array of bytes

type Shard

type Shard interface {
	GetDate() time.Time
	Add(records []Record) (int, error)
	GetAllCallback(callback QueryCallback) error
}

Shard is a date based shard of records. A shard must contain only records from the same UTC date

Jump to

Keyboard shortcuts

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