cockroachdb

package
v0.0.0-...-cfdbbe0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The lock TTL matches the default that Consul API uses, 15 seconds.
	// Used as part of SQL commands to set/extend lock expiry time relative to
	// database clock.
	CockroachDBLockTTLSeconds = 15

	// The amount of time to wait between the lock renewals
	CockroachDBLockRenewInterval = 5 * time.Second

	// CockroachDBLockRetryInterval is the amount of time to wait
	// if a lock fails before trying again.
	CockroachDBLockRetryInterval = time.Second
)

Variables

This section is empty.

Functions

func NewCockroachDBBackend

func NewCockroachDBBackend(conf map[string]string, logger log.Logger) (physical.Backend, error)

NewCockroachDBBackend constructs a CockroachDB backend using the given API client, server address, credentials, and database.

Types

type CockroachDBBackend

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

CockroachDBBackend Backend is a physical backend that stores data within a CockroachDB database.

func (*CockroachDBBackend) Delete

func (c *CockroachDBBackend) Delete(ctx context.Context, key string) error

Delete is used to permanently delete an entry

func (*CockroachDBBackend) Get

Get is used to fetch and entry.

func (*CockroachDBBackend) HAEnabled

func (c *CockroachDBBackend) HAEnabled() bool

func (*CockroachDBBackend) List

func (c *CockroachDBBackend) 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 (*CockroachDBBackend) LockWith

func (c *CockroachDBBackend) LockWith(key, value string) (physical.Lock, error)

func (*CockroachDBBackend) Put

func (c *CockroachDBBackend) Put(ctx context.Context, entry *physical.Entry) error

Put is used to insert or update an entry.

func (*CockroachDBBackend) Transaction

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

Transaction is used to run multiple entries via a transaction

type CockroachDBLock

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

func (*CockroachDBLock) Lock

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

Lock tries to acquire the lock by repeatedly trying to create a record in the CockroachDB table. It will block until either the stop channel is closed or the lock could be acquired successfully. The returned channel will be closed once the lock in the CockroachDB table cannot be renewed, either due to an error speaking to CockroachDB or because someone else has taken it.

func (*CockroachDBLock) Unlock

func (l *CockroachDBLock) Unlock() error

Unlock releases the lock by deleting the lock record from the CockroachDB table.

func (*CockroachDBLock) Value

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

Value checks whether or not the lock is held by any instance of CockroachDBLock, including this one, and returns the current value.

Jump to

Keyboard shortcuts

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