Documentation
¶
Overview ¶
Package dynamodb emulates Amazon DynamoDB and DynamoDB Streams over JSON 1.0: tables with global and local secondary indexes, every expression type, conditional writes, batches, transactions, TTL expiry and change streams.
Index ¶
- type Backup
- type Item
- type Record
- type Service
- func (s *Service) Apply(key string, v []byte) error
- func (s *Service) Close() error
- func (s *Service) DeleteItemJSON(account, region, table string, key map[string]any) error
- func (s *Service) ExpireTTL(now time.Time)
- func (s *Service) Info() core.Info
- func (s *Service) Inspect(table, id string) any
- func (s *Service) Items(account, region, table string, limit int) ([]map[string]any, error)
- func (s *Service) Load(b []byte) error
- func (s *Service) PutItemJSON(account, region, table string, item map[string]any) error
- func (s *Service) Reset()
- func (s *Service) Resources() []core.Table
- func (s *Service) Save() ([]byte, error)
- func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Service) SetJournal(j *core.Journal)
- func (s *Service) TaggedResources(account, region string) map[string]map[string]string
- type Stream
- type Table
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backup ¶
type Backup struct {
Arn string `json:"arn"`
Name string `json:"name"`
Account string `json:"account"`
Region string `json:"region"`
Created time.Time `json:"created"`
Deleted bool `json:"deleted,omitempty"`
Table *Table `json:"table"`
}
Backup is an on-demand backup: the table as it was, items included.
type Item ¶
Item is an item or a key: attribute name → value. Stored items are never changed in place (updates work on copies), so responses may share them.
type Record ¶
type Record struct {
EventID string `json:"eventID"`
EventName string `json:"eventName"`
EventVersion string `json:"eventVersion"`
EventSource string `json:"eventSource"`
AwsRegion string `json:"awsRegion"`
Dynamodb streamRecord `json:"dynamodb"`
UserIdentity *identity `json:"userIdentity,omitempty"`
}
Record is a stream record in the DynamoDB Streams (and Lambda event) shape.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the DynamoDB and DynamoDB Streams emulator.
func (*Service) Apply ¶
Apply replays a journal record: t/ tables (without items), i/ items, s/ streams, r/ stream records, x/ transaction tokens and b/ backups.
func (*Service) DeleteItemJSON ¶
DeleteItemJSON deletes the item with a key given in DynamoDB JSON, for the console.
func (*Service) ExpireTTL ¶
ExpireTTL deletes the items whose TTL attribute (epoch seconds) is at or before now, as the background sweeper does every few seconds. Like DynamoDB, it ignores TTLs more than five years in the past.
func (*Service) Inspect ¶
Inspect returns a table's description and up to 20 of its items. ponytail: tables are found by name alone; the first account/region wins.
func (*Service) Items ¶
Items returns up to limit items (all when limit <= 0) in DynamoDB JSON, e.g. {"id":{"S":"1"}}, for the console.
func (*Service) PutItemJSON ¶
PutItemJSON stores an item given in DynamoDB JSON, for the console.
func (*Service) ServeHTTP ¶
func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is core.RPC's JSON path plus apiError members and the X-Amz-Crc32 header, which DynamoDB SDKs verify.
func (*Service) SetJournal ¶
SetJournal logs every change of tables, items and streams (wal mode).
type Stream ¶
type Stream struct {
Arn string `json:"arn"`
Label string `json:"label"`
Table string `json:"table"`
Account string `json:"account"`
Region string `json:"region"`
View string `json:"view"`
Enabled bool `json:"enabled"`
Created time.Time `json:"created"`
Keys []keyElem `json:"keys"`
Shard string `json:"shard"`
Seq int64 `json:"seq"` // last sequence number handed out
Records []*Record `json:"records"`
}
Stream is a table's change stream: one shard with the latest records.
type Table ¶
type Table struct {
Name string `json:"name"`
Account string `json:"account"`
Region string `json:"region"`
ID string `json:"id"`
Created time.Time `json:"created"`
Attrs []attrDef `json:"attrs"`
Keys []keyElem `json:"keys"`
GSIs []*index `json:"gsis,omitempty"`
LSIs []*index `json:"lsis,omitempty"`
Billing string `json:"billing"`
Throughput *throughput `json:"throughput,omitempty"`
StreamArn string `json:"streamArn,omitempty"` // latest stream, possibly disabled
SSE *sseSpec `json:"sse,omitempty"`
Class string `json:"class"`
Protected bool `json:"protected,omitempty"`
TTL string `json:"ttl,omitempty"` // TTL attribute while enabled
PITR bool `json:"pitr,omitempty"`
Replicas []string `json:"replicas,omitempty"` // other regions of a global table
Restore *restoreSummary `json:"restore,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
Items map[string]Item `json:"items"` // keyOf(primary key) → item
}
Table is one table and its items.
type Value ¶
type Value struct {
S *string
N *string
B []byte
BOOL *bool
NULL bool
M map[string]*Value
L []*Value
SS []string
NS []string
BS [][]byte
}
Value is one attribute value in DynamoDB JSON. Exactly one field is set; nil means unset, so empty maps, lists and binaries survive a round trip.