storage

package
v0.0.0-...-4b84e57 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LockExpiration is the duration before which a Lock is considered expired
	LockExpiration = 1 * time.Minute
	// LockPollInterval is the interval between each check of the lock state.
	LockPollInterval = 1 * time.Second
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// AEAD for Authenticated Encryption with Additional Data
	AEAD tink.AEAD
	// BucketName is the name of the GCS storage Bucket
	BucketName string
	// ClientOptions GCS storage client options
	ClientOptions []option.ClientOption
}

type Storage

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

Storage is a certmagic.Storage backed by a GCS bucket

func NewStorage

func NewStorage(ctx context.Context, config Config) (*Storage, error)

func (*Storage) Delete

func (s *Storage) Delete(ctx context.Context, key string) error

Delete deletes key. An error should be returned only if the key still exists when the method returns.

func (*Storage) Exists

func (s *Storage) Exists(ctx context.Context, key string) bool

Exists returns true if the key exists and there was no error checking.

func (*Storage) List

func (s *Storage) List(ctx context.Context, prefix string, recursive bool) ([]string, error)

List returns all keys that match prefix. If recursive is true, non-terminal keys will be enumerated (i.e. "directories" should be walked); otherwise, only keys prefixed exactly by prefix will be listed.

func (*Storage) Load

func (s *Storage) Load(ctx context.Context, key string) ([]byte, error)

Load retrieves the value at key.

func (*Storage) Lock

func (s *Storage) Lock(ctx context.Context, key string) error

Lock acquires the lock for key, blocking until the lock can be obtained or an error is returned. Note that, even after acquiring a lock, an idempotent operation may have already been performed by another process that acquired the lock before - so always check to make sure idempotent operations still need to be performed after acquiring the lock.

The actual implementation of obtaining of a lock must be an atomic operation so that multiple Lock calls at the same time always results in only one caller receiving the lock at any given time.

To prevent deadlocks, all implementations (where this concern is relevant) should put a reasonable expiration on the lock in case Unlock is unable to be called due to some sort of network failure or system crash. Additionally, implementations should honor context cancellation as much as possible (in case the caller wishes to give up and free resources before the lock can be obtained).

func (*Storage) Stat

func (s *Storage) Stat(ctx context.Context, key string) (certmagic.KeyInfo, error)

Stat returns information about key.

func (*Storage) Store

func (s *Storage) Store(ctx context.Context, key string, value []byte) error

Store puts value at key.

func (*Storage) Unlock

func (s *Storage) Unlock(ctx context.Context, key string) error

Unlock releases the lock for key. This method must ONLY be called after a successful call to Lock, and only after the critical section is finished, even if it errored or timed out. Unlock cleans up any resources allocated during Lock.

Jump to

Keyboard shortcuts

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