Documentation
¶
Index ¶
- Constants
- func ChunkId(idProto *pb_almanac.ChunkId) (string, error)
- func ChunkIdProto(chunkId string) (*pb_almanac.ChunkId, error)
- func ChunkProto(entries []*pb_almanac.LogEntry, chunkType pb_almanac.ChunkId_Type) (*pb_almanac.Chunk, error)
- func NewChunkUid() string
- func Search(ctx context.Context, idx *index.Index, entries map[string]*pb_almanac.LogEntry, ...) ([]*pb_almanac.LogEntry, error)
- type Chunk
- type OldestEntryFirst
- type Storage
- func (s *Storage) DeleteChunk(ctx context.Context, chunkIdProto *pb_almanac.ChunkId) error
- func (s *Storage) ListChunks(ctx context.Context, startMs int64, endMs int64, ...) ([]string, error)
- func (s *Storage) LoadChunk(ctx context.Context, chunkIdProto *pb_almanac.ChunkId) (*Chunk, error)
- func (s *Storage) StoreChunk(ctx context.Context, chunkProto *pb_almanac.Chunk) (string, error)
Constants ¶
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 ¶
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) 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.
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 ¶
NewDiskStorage creates a backend backed by a root directory on disk. The supplied path must point to an existing empty directory.
func NewGcsStorage ¶
NewGcsStorage returns a storage backed by the supplied gcs bucket.
func NewMemoryStorage ¶
NewInMemoryStorage returns a storage backed by an in-memory map.
func (*Storage) DeleteChunk ¶
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 ¶
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 ¶
StoreChunk persists the supplied chunk proto in storage. Returns the id used to store the chunk.