gcs

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LockRenewInterval is the time to wait between lock renewals.
	LockRenewInterval = 5 * time.Second

	// LockRetryInterval is the amount of time to wait if the lock fails before
	// trying again.
	LockRetryInterval = 5 * time.Second

	// LockTTL is the default lock TTL.
	LockTTL = 15 * time.Second

	// LockWatchRetryInterval is the amount of time to wait if a watch fails
	// before trying again.
	LockWatchRetryInterval = 5 * time.Second

	// LockWatchRetryMax is the number of times to retry a failed watch before
	// signaling that leadership is lost.
	LockWatchRetryMax = 5
)

Variables

This section is empty.

Functions

func NewBackend added in v0.10.0

func NewBackend(c map[string]string, logger log.Logger) (physical.Backend, error)

NewBackend constructs a Google Cloud Storage backend with the given configuration. This uses the official Golang Cloud SDK and therefore supports specifying credentials via envvars, credential files, etc. from environment variables or a service account file

Types

type Backend added in v0.10.0

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

Backend implements physical.Backend and describes the steps necessary to persist data in Google Cloud Storage.

func (*Backend) Delete added in v0.10.0

func (b *Backend) Delete(ctx context.Context, key string) error

Delete deletes an entry with the given key

func (*Backend) Get added in v0.10.0

func (b *Backend) Get(ctx context.Context, key string) (retEntry *physical.Entry, retErr error)

Get fetches an entry. If no entry exists, this function returns nil.

func (*Backend) HAEnabled added in v0.10.0

func (b *Backend) HAEnabled() bool

HAEnabled implements HABackend and indicates that this backend supports high availability.

func (*Backend) List added in v0.10.0

func (b *Backend) List(ctx context.Context, prefix string) ([]string, error)

List is used to list all the keys under a given prefix, up to the next prefix.

func (*Backend) LockWith added in v0.10.0

func (b *Backend) LockWith(key, value string) (physical.Lock, error)

LockWith acquires a mutual exclusion based on the given key.

func (*Backend) Put added in v0.10.0

func (b *Backend) Put(ctx context.Context, entry *physical.Entry) (retErr error)

Put is used to insert or update an entry

type Lock added in v0.10.0

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

Lock is the HA lock.

func (*Lock) Lock added in v0.10.0

func (l *Lock) Lock(stopCh <-chan struct{}) (<-chan struct{}, error)

Lock acquires the given lock. The stopCh is optional. If closed, it interrupts the lock acquisition attempt. The returned channel should be closed when leadership is lost.

func (*Lock) Unlock added in v0.10.0

func (l *Lock) Unlock() error

Unlock releases the lock.

func (*Lock) Value added in v0.10.0

func (l *Lock) Value() (bool, string, error)

Value returns the value of the lock and if it is held.

type LockRecord added in v0.10.0

type LockRecord struct {
	Key       string    `json:"key"`
	Value     string    `json:"value"`
	Identity  string    `json:"identity"`
	Timestamp time.Time `json:"timestamp"`
	// contains filtered or unexported fields
}

LockRecord is the struct that corresponds to a lock.

Jump to

Keyboard shortcuts

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