Back to godoc.org
github.com/hashicorp/vault/physical/spanner

package spanner

v1.4.3
Latest Go to latest
Published: 4 days ago | License: MPL-2.0 | Module: github.com/hashicorp/vault

Index

Constants

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
)

func NewBackend

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

NewBackend creates a new Google Spanner storage backend with the given configuration. This uses the official Golang Cloud SDK and therefore supports specifying credentials via envvars, credential files, etc.

type Backend

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

Backend implements physical.Backend and describes the steps necessary to persist data using Google Cloud Spanner.

func (*Backend) Delete

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

Delete deletes an entry with the given key.

func (*Backend) Get

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

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

func (*Backend) HAEnabled

func (b *Backend) HAEnabled() bool

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

func (*Backend) List

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

List enumerates all keys with the given prefix.

func (*Backend) LockWith

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

LockWith acquires a mutual exclusion based on the given key.

func (*Backend) Put

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

Put creates or updates an entry.

func (*Backend) Transaction

func (b *Backend) Transaction(ctx context.Context, txns []*physical.TxnEntry) error

Transaction runs multiple entries via a single transaction.

type Lock

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

Lock is the HA lock.

func (*Lock) Lock

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

func (l *Lock) Unlock() error

Unlock releases the lock.

func (*Lock) Value

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

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

type LockRecord

type LockRecord struct {
	Key       string
	Value     string
	Identity  string
	Timestamp time.Time
}

LockRecord is the struct that corresponds to a lock.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier