gcs

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package gcs implements a blob store on Google Cloud Storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is a Google Cloud Storage-based implementation of a blob store. All blobs and other information are stored in a single GCS bucket.

A blob with ref R is stored in a bucket object named b:hex(R) (where hex(R) denotes the hexadecimal encoding of R).

A type annotation T for blob ref R is stored as a zero-length object named t:hex(R):hex(T).

An anchor with name N at time T pointing to ref R stores the bytes of R in an object named a:hex(N):nanos(M-T), where nanos denotes the representation of a time as a 30-digit number of nanoseconds since the Unix epoch (base 10, zero-padded), and M is the maximum useful time in Go, given by the formula:

time.Unix(1<<63-1-int64((1969*365+1969/4-1969/100+1969/400)*24*60*60), 999999999)

(see https://stackoverflow.com/a/32620397). This representation optimizes finding the latest anchor for a given name (in the common case) by querying the prefix a:hex(N):

func New

func New(bucket *storage.BucketHandle) *Store

New produces a new Store.

func (*Store) AnchorMapRef

func (s *Store) AnchorMapRef(ctx context.Context) (bs.Ref, error)

AnchorMapRef implements anchor.Getter.

func (*Store) Get

func (s *Store) Get(ctx context.Context, ref bs.Ref) (bs.Blob, error)

Get gets the blob with hash `ref`.

func (*Store) ListRefs

func (s *Store) ListRefs(ctx context.Context, start bs.Ref, f func(bs.Ref) error) error

ListRefs produces all blob refs in the store, in lexicographic order.

func (*Store) Put

func (s *Store) Put(ctx context.Context, b bs.Blob) (bs.Ref, bool, error)

Put adds a blob to the store if it wasn't already present.

func (*Store) UpdateAnchorMap

func (s *Store) UpdateAnchorMap(ctx context.Context, f anchor.UpdateFunc) error

UpdateAnchorMap implements anchor.Store.

Jump to

Keyboard shortcuts

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