storage

package
v0.0.0-...-1d7b8b3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StorageTypeMemory = "memory"
	StorageTypeDisk   = "disk"
	StorageTypeGcs    = "gcs"
)

Variables

This section is empty.

Functions

func ChunkId

func ChunkId(idProto *pb_almanac.ChunkId) (string, error)

ChunkId returns the string representation of the supplied chunk id proto.

func ChunkIdProto

func ChunkIdProto(chunkId string) (*pb_almanac.ChunkId, error)

ChunkIdProto returns the structured representation of the supplied chunk id.

func ChunkProto

func ChunkProto(entries []*pb_almanac.LogEntry, chunkType pb_almanac.ChunkId_Type) (*pb_almanac.Chunk, error)

ChunkProto is a one-stop-shop for creating a chunk proto from a set of entries.

func NewChunkUid

func NewChunkUid() string

NewChunkId returns a string which can be used as the "uid" part of a new chunk.

func Search(ctx context.Context, idx *index.Index, entries map[string]*pb_almanac.LogEntry, query string, num int32, startMs int64, endMs int64) ([]*pb_almanac.LogEntry, error)

Search executes a search on a given index and entry map. Results are returned in ascending order by timestamp.

Types

type Chunk

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

Chunk is an in-memory, immutable representation of a stored chunk. A chunk must be closed by calling Close() once it is no longer in use.

func (*Chunk) Close

func (c *Chunk) Close() error

Close releases any resources associated with this chunk.

func (*Chunk) Entries

func (c *Chunk) Entries() []*pb_almanac.LogEntry

Entries returns all the entries in this chunk. Callers must not modify the return value.

func (*Chunk) Id

func (c *Chunk) Id() *pb_almanac.ChunkId

Id returns the id of this chunk. Callers must not modify the return value.

func (*Chunk) Search

func (c *Chunk) Search(ctx context.Context, query string, num int32, startMs int64, endMs int64) ([]*pb_almanac.LogEntry, error)

Search returns all log entries in the chunk matching the supplied query, in ascending order by timestamp.

type OldestEntryFirst

type OldestEntryFirst []*pb_almanac.LogEntry

OldestEntryFirst is an ordering over log entries by ascending timestamp.

func (OldestEntryFirst) Len

func (a OldestEntryFirst) Len() int

func (OldestEntryFirst) Less

func (a OldestEntryFirst) Less(i, j int) bool

func (OldestEntryFirst) Swap

func (a OldestEntryFirst) Swap(i, j int)

type Storage

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

Storage stores chunks of log entries in persistent storage and supports various ways of loading and storing chunks.

func NewDiskStorage

func NewDiskStorage(path string) (*Storage, error)

NewDiskStorage creates a backend backed by a root directory on disk. The supplied path must point to an existing empty directory.

func NewGcsStorage

func NewGcsStorage(bucketName string) (*Storage, error)

NewGcsStorage returns a storage backed by the supplied gcs bucket.

func NewMemoryStorage

func NewMemoryStorage() (*Storage, error)

NewInMemoryStorage returns a storage backed by an in-memory map.

func (*Storage) DeleteChunk

func (s *Storage) DeleteChunk(ctx context.Context, chunkIdProto *pb_almanac.ChunkId) error

func (*Storage) ListChunks

func (s *Storage) ListChunks(ctx context.Context, startMs int64, endMs int64, chunkType pb_almanac.ChunkId_Type) ([]string, error)

ListChunks returns the ids of all stored chunks which overlap with the supplied time range (inclusive on both ends).

func (*Storage) LoadChunk

func (s *Storage) LoadChunk(ctx context.Context, chunkIdProto *pb_almanac.ChunkId) (*Chunk, error)

LoadChunk loads the chunk with the supplied id. The returned chunk uses resources which must be freed once it is no longer in use.

func (*Storage) StoreChunk

func (s *Storage) StoreChunk(ctx context.Context, chunkProto *pb_almanac.Chunk) (string, error)

StoreChunk persists the supplied chunk proto in storage. Returns the id used to store the chunk.

Jump to

Keyboard shortcuts

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