dynamodb

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package dynamodb implements the exchange.Store interface on top of DynamoDB.

Data model (single table, no secondary indexes). Items are grouped into one partition per time resolution:

pk = "rates#raw"     sk = <nanos>          rates             (every sample)
pk = "rates#hour"    sk = <hour-start>     ts, rates         (close per hour)
pk = "rates#day"     sk = <day-start>      ts, rates         (close per day)
pk = "rates#week"    sk = <week-start>     ts, rates         (close per week, Sunday-start)
pk = "rates#month"   sk = <month-start>    ts, rates         (close per month)

Every item carries the full symbol->rate map for that instant; rollup items hold the map from the most recent sample in their bucket (the "close"). The sort key is the bucket-start time as unix-nanos (a Number), which sorts in chronological order. Rollup items also store `ts`, the close sample's actual time, which both drives the monotonic last-write-wins guard and is the timestamp returned for the point. Raw items omit `ts` because their sort key already is the sample time.

Writes fan out to all resolutions in a single transaction: the raw point is a conditional Put that enforces the once-per-timestamp contract, and each rollup is a monotonic last-write-wins Update. Reads serve the resolution matching the requested interval (see resolutionForInterval): the caller chooses an interval appropriate to the range and the store honors it directly. Point lookups always read the raw resolution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTables

func CreateTables(ctx context.Context, client *dynamodb.Client, table string) error

CreateTables provisions the exchange rate table with on-demand billing. The table is keyed by (pk, sk) with no secondary indexes. It is idempotent: a table that already exists is left as-is. The call blocks until the table is ACTIVE.

func New

func New(client *dynamodb.Client, table string) exchange.Store

New returns an exchange.Store backed by the given DynamoDB table. Use CreateTables to provision it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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