dynamodb

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package dynamodb retrieves configuration values from an AWS DynamoDB table.

New wraps an application-owned AWS SDK v2 Client using Config for the table and attribute names. Provider.Get retrieves one value and Provider.GetMultiple queries a configuration path, including paginated results. Their option types combine SDK requests with Parameters cache and transforms.

Table and cache policy

The application provisions the table, keys and permissions. This adapter does not create tables. Successful retrievals are cached according to Parameters policy; Provider.ClearCache invalidates local entries. Missing-value and transform behavior are explicit options, and errors retain SDK error chains.

For usage and compatibility details, see the user guide.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GetItem(context.Context, *sdk.GetItemInput, ...func(*sdk.Options)) (*sdk.GetItemOutput, error)
	Query(context.Context, *sdk.QueryInput, ...func(*sdk.Options)) (*sdk.QueryOutput, error)
}

type Config

type Config struct{ TableName, KeyAttribute, SortAttribute, ValueAttribute string }

type GetOptions

type GetOptions struct {
	parameters.Options
	SDKOptions *sdk.GetItemInput
}

type MultipleOptions

type MultipleOptions struct {
	parameters.Options
	SDKOptions *sdk.QueryInput
}

type Provider

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

func New

func New(client Client, config Config) (*Provider, error)

func (*Provider) ClearCache

func (p *Provider) ClearCache()

func (*Provider) Get

func (p *Provider) Get(ctx context.Context, name string, options GetOptions) (any, error)
Example

This example requires AWS credentials and a configuration table with data.

package main

import (
	"context"

	"github.com/aws/aws-sdk-go-v2/config"
	sdk "github.com/aws/aws-sdk-go-v2/service/dynamodb"
	"github.com/rambow-cloud/powertools-lambda-go/parameters/dynamodb"
)

func main() {
	ctx := context.Background()
	cfg, err := config.LoadDefaultConfig(ctx)
	if err != nil {
		panic(err)
	}
	provider, err := dynamodb.New(sdk.NewFromConfig(cfg), dynamodb.Config{
		TableName: "example-configuration", KeyAttribute: "id", ValueAttribute: "value",
	})
	if err != nil {
		panic(err)
	}
	value, err := provider.Get(ctx, "feature", dynamodb.GetOptions{})
	if err != nil {
		panic(err)
	}
	_ = value
}

func (*Provider) GetMultiple

func (p *Provider) GetMultiple(ctx context.Context, path string, options MultipleOptions) (map[string]any, error)

Jump to

Keyboard shortcuts

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