luci: go.chromium.org/luci/logdog/common/storage/bigtable Index | Files | Directories

package bigtable

import "go.chromium.org/luci/logdog/common/storage/bigtable"

Package bigtable provides an implementation of the Storage interface backed by Google Cloud Platform's BigTable.

Intermediate Log Table

The Intermediate Log Table stores LogEntry protobufs that have been ingested, but haven't yet been archived. It is a tall table whose rows are keyed off of the log's (Path,Stream-Index) in that order.

Each entry in the table will contain the following schema:

- Column Family "log"
  - Column "data": the LogEntry raw protobuf data. Soft size limit of ~1MB.

The log path is the composite of the log's (Prefix, Name) properties. Logs belonging to the same stream will share the same path, so they will be clustered together and suitable for efficient iteration. Immediately following the path will be the log's stream index.

[            20 bytes          ]     ~    [       1-5 bytes      ]
 B64(SHA256(Path(Prefix, Name)))  + '~' + HEX(cmpbin(StreamIndex))

As there is no (technical) size constraint to either the Prefix or Name values, they will both be hashed using SHA256 to produce a unique key representing that specific log stream.

This allows a key to be generated representing "immediately after the row" by appending two '~' characters to the base hash. Since the second '~' character is always greater than any HEX(cmpbin(*)) value, this will effectively upper-bound the row.

"cmpbin" (go.chromium.org/luci/common/cmpbin) will be used to format the stream index. It is a variable-width number encoding scheme that offers the guarantee that byte-sorted encoded numbers will maintain the same order as the numbers themselves.

Index

Package Files

bigtable.go cache.go doc.go initialize.go rowKey.go storage.go testing.go

Constants

const DefaultMaxLogAge = time.Duration(7 * 24 * time.Hour)

DefaultMaxLogAge is the maximum age of a log (7 days).

Variables

var (
    // StorageScopes is the set of OAuth scopes needed to use the storage
    // functionality.
    StorageScopes = []string{
        bigtable.Scope,
    }

    // StorageReadOnlyScopes is the set of OAuth scopes needed to use the storage
    // functionality.
    StorageReadOnlyScopes = []string{
        bigtable.ReadonlyScope,
    }
)
var InitializeScopes = []string{
    bigtable.AdminScope,
}

InitializeScopes is the set of OAuth scopes needed to use the Initialize functionality.

func DefaultClientOptions Uses

func DefaultClientOptions() []option.ClientOption

DefaultCallOptions returns a function set of ClientOptions to apply to a BigTable client.

type Storage Uses

type Storage struct {
    // Client, if not nil, is the BigTable client to use for BigTable accesses.
    Client *bigtable.Client

    // AdminClient, if not nil, is the BigTable admin client to use for BigTable
    // administrator operations.
    AdminClient *bigtable.AdminClient

    // LogTable is the name of the BigTable table to use for logs.
    LogTable string

    // Cache, if not nil, will be used to cache data.
    Cache storage.Cache
    // contains filtered or unexported fields
}

Storage is a BigTable storage configuration client.

func (*Storage) Close Uses

func (s *Storage) Close()

Close implements storage.Storage.

func (*Storage) Config Uses

func (s *Storage) Config(c context.Context, cfg storage.Config) error

Config implements storage.Storage.

func (*Storage) Get Uses

func (s *Storage) Get(c context.Context, r storage.GetRequest, cb storage.GetCallback) error

Get implements storage.Storage.

func (*Storage) Initialize Uses

func (s *Storage) Initialize(c context.Context) error

Initialize sets up a Storage schema in BigTable. If the schema is already set up properly, no action will be taken.

If, however, the table or table's schema doesn't exist, Initialize will create and configure it.

If nil is returned, the table is ready for use as a Storage via New.

func (*Storage) Put Uses

func (s *Storage) Put(c context.Context, r storage.PutRequest) error

Put implements storage.Storage.

func (*Storage) Tail Uses

func (s *Storage) Tail(c context.Context, project types.ProjectName, path types.StreamPath) (*storage.Entry, error)

Tail implements storage.Storage.

type Testing Uses

type Testing interface {
    storage.Storage

    DataMap() map[string][]byte
    SetMaxRowSize(int)
    SetErr(error)
    MaxLogAge() time.Duration
}

Testing is an extension of storage.Storage with additional testing capabilities.

func NewMemoryInstance Uses

func NewMemoryInstance(cache storage.Cache) Testing

NewMemoryInstance returns an in-memory BigTable Storage implementation. This can be supplied in the Raw field in Options to simulate a BigTable connection.

An optional cache can be supplied to test caching logic.

Close should be called on the resulting value after the user is finished in order to free resources.

Directories

PathSynopsis
logdog_bigtable_testPackage main implements a simple CLI tool to load and interact with storage data in Google BigTable data.

Package bigtable imports 27 packages (graph) and is imported by 8 packages. Updated 2018-10-18. Refresh now. Tools for package owners.