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, table string, r Reading, update string, ...) error
- func Delete(ctx context.Context, table string, r Reading) error
- func Each(ctx context.Context, table, keyCond string, opts ...dynamodb.QueryOption) iter.Seq2[Reading, error]
- func Page(ctx context.Context, table, keyCond string, opts ...dynamodb.QueryOption) (dynamobind.Page[Reading], error)
- func ReadingTable(name string) dynamodb.TableDefinition
- func ReadingsBetween(ctx context.Context, sensor Sensor, low int64, high int64, ...) (dynamobind.Page[Reading], error)
- func ReadingsForSensor(ctx context.Context, sensor Sensor, opts ...dynamodb.QueryOption) iter.Seq2[Reading, error]
- func ReadingsSince(ctx context.Context, sensor Sensor, from int64, opts ...dynamodb.QueryOption) iter.Seq2[Reading, error]
- func Save(ctx context.Context, table string, r Reading) error
- func Sweep(ctx context.Context, table string, opts ...dynamodb.ScanOption) iter.Seq2[Reading, error]
- func Table(name string) dynamodb.TableDefinition
- type Reading
- func Fetch(ctx context.Context, table string, key dynamodb.Key) (Reading, error)
- func FetchAll(ctx context.Context, table string, keys []dynamodb.Key) ([]Reading, []dynamodb.Key, error)
- func Replace(ctx context.Context, table string, r Reading) (Reading, bool, error)
- func Retire(ctx context.Context, table string, r Reading) (Reading, bool, error)
- func SaveAll(ctx context.Context, 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, 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, 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 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 FetchAll ¶
func FetchAll(ctx context.Context, table string, keys []dynamodb.Key) ([]Reading, []dynamodb.Key, error)
FetchAll reads every key, 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.