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 ¶
- func Correct(ctx context.Context, c *dynamodb.Client, table string, r Reading, ...) error
- func Delete(ctx context.Context, c *dynamodb.Client, table string, r Reading) error
- func Each(ctx context.Context, c *dynamodb.Client, table, keyCond string, ...) iter.Seq2[Reading, error]
- func Page(ctx context.Context, c *dynamodb.Client, table, keyCond string, ...) (dynamobind.Page[Reading], error)
- func ReadingTable(name string) dynamodb.TableDefinition
- func Save(ctx context.Context, c *dynamodb.Client, table string, r Reading) error
- func Sweep(ctx context.Context, c *dynamodb.Client, table string, ...) iter.Seq2[Reading, error]
- func Table(name string) dynamodb.TableDefinition
- type Reading
- func Fetch(ctx context.Context, c *dynamodb.Client, table string, key dynamodb.Key) (Reading, error)
- func FetchAll(ctx context.Context, c *dynamodb.Client, table string, keys []dynamodb.Key) ([]Reading, []dynamodb.Key, error)
- func Replace(ctx context.Context, c *dynamodb.Client, table string, r Reading) (Reading, bool, error)
- func Retire(ctx context.Context, c *dynamodb.Client, table string, r Reading) (Reading, bool, error)
- func SaveAll(ctx context.Context, c *dynamodb.Client, table string, rs []Reading) ([]Reading, error)
- type Sensor
- type Site
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Correct ¶
func Correct(ctx context.Context, c *dynamodb.Client, table string, r Reading, update string, opts ...dynamodb.WriteOption) error
Correct applies an update expression to the reading sharing r's key.
func Each ¶
func Each(ctx context.Context, c *dynamodb.Client, 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, c *dynamodb.Client, 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 Sweep ¶
func Sweep(ctx context.Context, c *dynamodb.Client, 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, c *dynamodb.Client, table string, key dynamodb.Key) (Reading, error)
Fetch reads one reading by key.
func FetchAll ¶
func FetchAll(ctx context.Context, c *dynamodb.Client, table string, keys []dynamodb.Key) ([]Reading, []dynamodb.Key, error)
FetchAll reads every key, in requests DynamoDB accepts.
func Replace ¶
func Replace(ctx context.Context, c *dynamodb.Client, 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, c *dynamodb.Client, 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, c *dynamodb.Client, table string, rs []Reading) ([]Reading, error)
SaveAll stores every reading, in requests DynamoDB accepts.
func (*Reading) DecodeItem ¶
DecodeItem fills Reading from a DynamoDB item. An attribute the item does not carry leaves its field untouched.
func (Reading) EncodeItem ¶
EncodeItem converts Reading into a DynamoDB item.
type Sensor ¶
type Sensor string
Sensor is a named string, so the codec has to convert rather than assign.
type Site ¶
Site is a nested item, stored as an M attribute.
func (*Site) DecodeItem ¶
DecodeItem fills Site from a DynamoDB item. An attribute the item does not carry leaves its field untouched.
func (Site) EncodeItem ¶
EncodeItem converts Site into a DynamoDB item.