persistence

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigProvider

type ConfigProvider = client.ConfigProvider

ConfigProvider is an alias for the AWS SDK ConfigProvider interface.

type DynamoDBClientAPI

type DynamoDBClientAPI interface {
	GetItemWithContext(aws.Context, *dynamodb.GetItemInput, ...request.Option) (*dynamodb.GetItemOutput, error)
	PutItemWithContext(aws.Context, *dynamodb.PutItemInput, ...request.Option) (*dynamodb.PutItemOutput, error)
	QueryWithContext(aws.Context, *dynamodb.QueryInput, ...request.Option) (*dynamodb.QueryOutput, error)
}

DynamoDBClientAPI is an interface that defines the methods used from the DynamoDB client.

type DynamoDBEnvelope

type DynamoDBEnvelope struct {
	Revoked       bool                   `json:"Revoked,omitempty"`
	Created       int64                  `json:"Created"`
	EncryptedKey  string                 `json:"Key"`
	ParentKeyMeta *appencryption.KeyMeta `json:"ParentKeyMeta,omitempty"`
}

DynamoDBEnvelope is used to convert the EncryptedKey to a Base64 encoded string to save in DynamoDB.

type DynamoDBMetastore

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

DynamoDBMetastore implements the Metastore interface.

func NewDynamoDBMetastore

func NewDynamoDBMetastore(sess ConfigProvider, opts ...DynamoDBMetastoreOption) *DynamoDBMetastore

NewDynamoDBMetastore creates a new DynamoDBMetastore with the provided session and options.

func (*DynamoDBMetastore) GetClient

func (d *DynamoDBMetastore) GetClient() DynamoDBClientAPI

GetClient returns the DynamoDB client.

func (*DynamoDBMetastore) GetRegionSuffix

func (d *DynamoDBMetastore) GetRegionSuffix() string

GetRegionSuffix returns the DynamoDB region suffix or blank if not configured.

func (*DynamoDBMetastore) GetTableName

func (d *DynamoDBMetastore) GetTableName() string

GetTableName returns the DynamoDB table name.

func (*DynamoDBMetastore) Load

Load returns the key matching the keyID and created times provided. The envelope will be nil if it does not exist in the metastore.

func (*DynamoDBMetastore) LoadLatest

LoadLatest returns the newest record matching the keyID. The return value will be nil if not already present.

func (*DynamoDBMetastore) Store

func (d *DynamoDBMetastore) Store(ctx context.Context, keyID string, created int64, envelope *appencryption.EnvelopeKeyRecord) (bool, error)

Store attempts to insert the key into the metastore if one is not already present. If a key exists, the method will return false. If one is not present, the value will be inserted and we return true.

type DynamoDBMetastoreOption

type DynamoDBMetastoreOption func(d *DynamoDBMetastore, p ConfigProvider)

DynamoDBMetastoreOption is used to configure additional options in a DynamoDBMetastore.

func WithClient

WithClient configures the DynamoDBMetastore to use the provided client.

This is useful for testing or when you want to use a custom DynamoDB client.

func WithDynamoDBRegionSuffix

func WithDynamoDBRegionSuffix(enabled bool) DynamoDBMetastoreOption

WithDynamoDBRegionSuffix configures the DynamoDBMetastore to use a regional suffix for all writes. This feature should be enabled when using DynamoDB global tables to avoid write conflicts arising from the "last writer wins" method of conflict resolution.

func WithTableName

func WithTableName(table string) DynamoDBMetastoreOption

WithTableName configures the DynamoDBMetastore to use the specified table name.

Jump to

Keyboard shortcuts

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