storage

package
v0.0.0-...-a364eb7 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTableName = "stopgap"

DefaultTableName is used when a more specific name isn't provided.

Variables

View Source
var ErrCreateTimedOut = errors.New("timed out waiting for table creation")

ErrCreateTimedOut is returned when table creation takes too long.

View Source
var ErrDeleteInProgress = errors.New("table deletion in progress")

ErrDeleteInProgress is returned when table creation fails because a table with the same name was recently deleted.

Functions

This section is empty.

Types

type DynamoStore

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

DynamoStore stores mutex data in DynamoDB.

func New

func New(svc *dynamodb.Client) *DynamoStore

New creates a DynamoStore instance using default values.

func NewWithTableName

func NewWithTableName(svc *dynamodb.Client, table string) *DynamoStore

NewWithTableName create a DynamoStore instance, overriding the default table name.

func (*DynamoStore) CreateMutex

func (s *DynamoStore) CreateMutex(rqx *rqx.RequestContext, name, description string) error

CreateMutex adds the named mutex.

func (*DynamoStore) CreateTable

func (s *DynamoStore) CreateTable() error

CreateTable creates the DynamoStore table, if it doesn't already exist. This is only intended as a convenience function to make development and testing easier. It is not intended for use in production.

func (*DynamoStore) GetMutex

func (s *DynamoStore) GetMutex(name string, consistent bool) (*Mutex, error)

GetMutex returns the data for a given mutex from the DynamoStore instance.

func (*DynamoStore) LockMutex

func (s *DynamoStore) LockMutex(rqx *rqx.RequestContext, name, message string) error

LockMutex locks the named mutex.

func (*DynamoStore) UnlockMutex

func (s *DynamoStore) UnlockMutex(rqx *rqx.RequestContext, name string) error

UnlockMutex unlocks the named mutex.

type Mutex

type Mutex struct {
	Version     int64
	Description string
	Locked      bool
	LockedBy    string
	Message     string
}

Mutex can be used to coordinate access to shared resources.

type MutexRepoFake

type MutexRepoFake struct {
	Retries int
	Mutexes map[string]string
}

MutexRepoFake should only be used in tests.

func NewMutexRepoFake

func NewMutexRepoFake() *MutexRepoFake

NewMutexRepoFake creates a DynamoStore instance using default values.

func (*MutexRepoFake) CreateMutex

func (r *MutexRepoFake) CreateMutex(rqx *rqx.RequestContext, name, description string) error

CreateMutex adds the named mutex.

func (*MutexRepoFake) LockMutex

func (r *MutexRepoFake) LockMutex(rqx *rqx.RequestContext, name, message string) error

LockMutex locks the named mutex.

func (*MutexRepoFake) UnlockMutex

func (r *MutexRepoFake) UnlockMutex(rqx *rqx.RequestContext, name string) error

UnlockMutex unlocks the named mutex.

Jump to

Keyboard shortcuts

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