dynamofixture

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package dynamofixture exercises the generated DynamoDB item codec against the dynamobind runtime and the driver's wire protocol.

The calls below are what generation is directed by: each one names the type it binds, and the generator emits exactly the methods those calls need.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Correct

func Correct(ctx context.Context, table string, r Reading, update string, opts ...dynamodb.WriteOption) error

Correct applies an update expression to the reading sharing r's key.

func Delete

func Delete(ctx context.Context, table string, r Reading) error

Delete removes the reading sharing r's key.

func Each

func Each(ctx context.Context, table, keyCond string, opts ...dynamodb.QueryOption) iter.Seq2[Reading, error]

Each iterates every reading a query matches, one request per page.

func Page

func Page(ctx context.Context, table, keyCond string, opts ...dynamodb.QueryOption) (dynamobind.Page[Reading], error)

Page reads one page of a sensor's readings.

func ReadingTable

func ReadingTable(name string) dynamodb.TableDefinition

ReadingTable describes the table Reading is stored in. The key names come from the same tags as the codec, so they cannot drift apart.

func ReadingsBetween added in v0.2.9

func ReadingsBetween(ctx context.Context, sensor Sensor, low int64, high int64, opts ...dynamodb.QueryOption) (dynamobind.Page[Reading], error)

ReadingsBetween queries Reading in readings.

func ReadingsForSensor added in v0.2.9

func ReadingsForSensor(ctx context.Context, sensor Sensor, opts ...dynamodb.QueryOption) iter.Seq2[Reading, error]

ReadingsForSensor queries Reading in readings.

func ReadingsSince added in v0.2.9

func ReadingsSince(ctx context.Context, sensor Sensor, from int64, opts ...dynamodb.QueryOption) iter.Seq2[Reading, error]

ReadingsSince queries Reading in readings.

func Save

func Save(ctx context.Context, table string, r Reading) error

Save stores one reading, replacing whatever shared its key.

func Sweep

func Sweep(ctx context.Context, table string, opts ...dynamodb.ScanOption) iter.Seq2[Reading, error]

Sweep iterates a whole table.

func Table

func Table(name string) dynamodb.TableDefinition

Table describes the table these readings live in.

Types

type Reading

type Reading struct {
	Sensor Sensor    `dynamo:"sensor,partitionkey"`
	At     int64     `dynamo:"at,sortkey"`
	Note   string    `dynamo:"note"`
	Scale  float32   `dynamo:"scale"`
	Count  uint16    `dynamo:"count"`
	Active bool      `dynamo:"active"`
	Blob   []byte    `dynamo:"blob"`
	Taken  time.Time `dynamo:"taken"`
	Seen   time.Time `dynamo:"seen,unixtime"`

	Tags   []string          `dynamo:"tags,stringset,omitempty"`
	Counts []int             `dynamo:"counts,numberset,omitempty"`
	Chunks [][]byte          `dynamo:"chunks,binaryset,omitempty"`
	Words  []Sensor          `dynamo:"words"`
	Scores map[string]int32  `dynamo:"scores"`
	Sites  map[string]string `dynamo:"sites,omitempty"`

	Site    Site  `dynamo:"site"`
	Backup  *Site `dynamo:"backup"`
	Skipped int   `dynamo:"-"`

	// Exact is the escape hatch: a number with more significant digits than any
	// Go type carries stays text from end to end through it.
	Exact dynamodb.AttributeValue `dynamo:"exact"`
}

Reading covers every attribute form the generator supports.

func Fetch

func Fetch(ctx context.Context, table string, key dynamodb.Key) (Reading, error)

Fetch reads one reading by key.

func FetchAll

func FetchAll(ctx context.Context, table string, keys []dynamodb.Key) ([]Reading, []dynamodb.Key, error)

FetchAll reads every key, in requests DynamoDB accepts.

func Replace

func Replace(ctx context.Context, table string, r Reading) (Reading, bool, error)

Replace stores one reading and returns the one it replaced, if any.

func Retire

func Retire(ctx context.Context, table string, r Reading) (Reading, bool, error)

Retire deletes the reading sharing r's key and returns what was deleted.

func SaveAll

func SaveAll(ctx context.Context, table string, rs []Reading) ([]Reading, error)

SaveAll stores every reading, in requests DynamoDB accepts.

func (*Reading) DecodeItem

func (v *Reading) DecodeItem(item dynamodb.Item) error

DecodeItem fills Reading from a DynamoDB item. An attribute the item does not carry leaves its field untouched.

func (Reading) EncodeItem

func (v Reading) EncodeItem() dynamodb.Item

EncodeItem converts Reading into a DynamoDB item.

func (Reading) ItemKey

func (v Reading) ItemKey() dynamodb.Key

ItemKey returns the primary key of Reading.

type Sensor

type Sensor string

Sensor is a named string, so the codec has to convert rather than assign.

type Site

type Site struct {
	City string `dynamo:"city"`
	Zip  string `dynamo:"zip,omitempty"`
}

Site is a nested item, stored as an M attribute.

func (*Site) DecodeItem

func (v *Site) DecodeItem(item dynamodb.Item) error

DecodeItem fills Site from a DynamoDB item. An attribute the item does not carry leaves its field untouched.

func (Site) EncodeItem

func (v Site) EncodeItem() dynamodb.Item

EncodeItem converts Site into a DynamoDB item.

Jump to

Keyboard shortcuts

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