storage

package
v0.0.0-...-27aecd8 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDataPath

func GetDataPath(path string) string

func GetIndexPath

func GetIndexPath(path string) string

func GetTmpPath

func GetTmpPath(path string) string

func OpenIndexFile

func OpenIndexFile(path string) (*os.File, error)

Types

type Chunk

type Chunk struct {
	Index *Index

	Path string
	// contains filtered or unexported fields
}

func CreateChunk

func CreateChunk(storagePath string) (*Chunk, error)

func OpenChunk

func OpenChunk(path string) (*Chunk, error)

func (*Chunk) Close

func (c *Chunk) Close() error

func (*Chunk) Finalize

func (c *Chunk) Finalize() error

func (*Chunk) Flush

func (c *Chunk) Flush()

func (*Chunk) ForEachActiveRecord

func (c *Chunk) ForEachActiveRecord(repeatTimeout time.Duration, handler ChunkRecordHandler)

func (*Chunk) Restore

func (c *Chunk) Restore(record IndexRecord) ([]byte, error)

func (*Chunk) Store

func (c *Chunk) Store(data DataRecord) error

type ChunkRecordHandler

type ChunkRecordHandler func(*Chunk, IndexRecord) bool

type Data

type Data interface {
	Close()
	Save(io.Writer) (int, error)
}

type DataRecord

type DataRecord struct {
	Data    Data
	TTL     int32
	LastTry time.Time
}

type Index

type Index struct {
	Header  *IndexHeader
	Records []IndexRecord
	// contains filtered or unexported fields
}

func CreateIndex

func CreateIndex(file *os.File) (*Index, error)

func OpenIndex

func OpenIndex(file *os.File) (*Index, error)

func (*Index) AppendRecord

func (index *Index) AppendRecord() (*IndexRecord, error)

func (*Index) Close

func (index *Index) Close() error

func (*Index) Flush

func (index *Index) Flush() error

type IndexHeader

type IndexHeader struct {
	Magic       int32
	Version     int32
	Length      int64 // in elements number
	ActiveCount int64
}

type IndexRecord

type IndexRecord struct {
	TTL     int32
	LastTry time.Time
	Offset  int64 // in bytes
	Size    int64 // in bytes
}

type Storer

type Storer struct {
	Chunks chan string
	// contains filtered or unexported fields
}

func NewStorer

func NewStorer(logger *logging.Logger, storage string, repeatNumber int32,
	chunkLifetime time.Duration, bufferSize int) (*Storer, error)

func StartStorer

func StartStorer(logger *logging.Logger, storage string, repeatNumber int32,
	chunkLifetime time.Duration, bufferSize int) (*Storer, error)

func (*Storer) Add

func (s *Storer) Add(data Data)

func (*Storer) AddWithTTL

func (s *Storer) AddWithTTL(data Data, ttl int32)

func (*Storer) Spawn

func (s *Storer) Spawn()

func (*Storer) Stop

func (s *Storer) Stop()

Jump to

Keyboard shortcuts

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