Documentation ¶
Index ¶
- Constants
- func IsInvalidFieldNameError(err error) bool
- func IsItemNotFoundError(err error) bool
- func IsMismatchedValueCountError(err error) bool
- func TableName(eventSourceARN string) (string, bool)
- type Change
- type ConsumedCapacity
- type DDB
- func (d *DDB) MustTable(tableName string, model interface{}) *Table
- func (d *DDB) Table(tableName string, model interface{}) (*Table, error)
- func (d *DDB) TransactGetItems(items ...GetTx) error
- func (d *DDB) TransactGetItemsWithContext(ctx context.Context, gets ...GetTx) (err error)
- func (d *DDB) TransactWriteItems(items ...WriteTx) (*dynamodb.TransactWriteItemsOutput, error)
- func (d *DDB) TransactWriteItemsWithContext(ctx context.Context, items ...WriteTx) (*dynamodb.TransactWriteItemsOutput, error)
- func (d *DDB) WithTokenFunc(fn func() string) *DDB
- func (d *DDB) WithTransactAttempts(n int) *DDB
- func (d *DDB) WithTransactTimeout(fn func(i int) time.Duration) *DDB
- type Delete
- func (d *Delete) Condition(expr string, values ...interface{}) *Delete
- func (d *Delete) ConsumedCapacity(capture *ConsumedCapacity) *Delete
- func (d *Delete) DeleteItemInput() (*dynamodb.DeleteItemInput, error)
- func (d *Delete) Range(rangeKey interface{}) *Delete
- func (d *Delete) ReturnValuesOnConditionCheckFailure(value string) *Delete
- func (d *Delete) Run() error
- func (d *Delete) RunWithContext(ctx context.Context) error
- func (d *Delete) Tx() (*dynamodb.TransactWriteItem, error)
- type EpochSeconds
- type Error
- type Event
- type Get
- func (g *Get) ConsistentRead(enabled bool) *Get
- func (g *Get) ConsumedCapacity(capture *ConsumedCapacity) *Get
- func (g *Get) GetItemInput() (*dynamodb.GetItemInput, error)
- func (g *Get) Range(value interface{}) *Get
- func (g *Get) Scan(v interface{}) error
- func (g *Get) ScanTx(v interface{}) GetTx
- func (g *Get) ScanWithContext(ctx context.Context, v interface{}) error
- type GetTx
- type Int64Set
- type Item
- type Put
- func (p *Put) Condition(expr string, values ...interface{}) *Put
- func (p *Put) ConsumedCapacity(capture *ConsumedCapacity) *Put
- func (p *Put) PutItemInput() (*dynamodb.PutItemInput, error)
- func (p *Put) ReturnValuesOnConditionCheckFailure(value string) *Put
- func (p *Put) Run() error
- func (p *Put) RunWithContext(ctx context.Context) error
- func (p *Put) Tx() (*dynamodb.TransactWriteItem, error)
- type Query
- func (q *Query) ConsistentRead(enabled bool) *Query
- func (q *Query) ConsumedCapacity(capture *ConsumedCapacity) *Query
- func (q *Query) Each(fn func(item Item) (bool, error)) error
- func (q *Query) EachWithContext(ctx context.Context, fn func(item Item) (bool, error)) (err error)
- func (q *Query) Filter(expr string, values ...interface{}) *Query
- func (q *Query) FindAll(v interface{}) error
- func (q *Query) FindAllWithContext(ctx context.Context, v interface{}) error
- func (q *Query) First(v interface{}) error
- func (q *Query) FirstWithContext(ctx context.Context, v interface{}) error
- func (q *Query) IndexName(indexName string) *Query
- func (q *Query) KeyCondition(expr string, values ...interface{}) *Query
- func (q *Query) LastEvaluatedKey(lastEvaluatedKey *map[string]*dynamodb.AttributeValue) *Query
- func (q *Query) LastEvaluatedToken(lastEvaluatedToken *string) *Query
- func (q *Query) Limit(limit int64) *Query
- func (q *Query) QueryInput() (*dynamodb.QueryInput, error)
- func (q *Query) ScanIndexForward(enabled bool) *Query
- func (q *Query) Select(s string) *Query
- func (q *Query) StartKey(startKey map[string]*dynamodb.AttributeValue) *Query
- func (q *Query) StartToken(token string) *Query
- type Record
- type Scan
- func (s *Scan) ConsistentRead(enabled bool) *Scan
- func (s *Scan) ConsumedCapacity(capture *ConsumedCapacity) *Scan
- func (s *Scan) Debug(w io.Writer) *Scan
- func (s *Scan) Each(callback func(item Item) (bool, error)) error
- func (s *Scan) EachWithContext(ctx context.Context, callback func(item Item) (bool, error)) error
- func (s *Scan) Filter(expr string, values ...interface{}) *Scan
- func (s *Scan) First(v interface{}) error
- func (s *Scan) FirstWithContext(ctx context.Context, v interface{}) error
- func (s *Scan) IndexName(indexName string) *Scan
- func (s *Scan) TotalSegments(n int64) *Scan
- type StringSet
- func (ss StringSet) Contains(want string) bool
- func (ss StringSet) ContainsRegexp(re *regexp.Regexp) bool
- func (ss StringSet) MarshalDynamoDBAttributeValue(item *dynamodb.AttributeValue) error
- func (ss StringSet) StringSlice() []string
- func (ss StringSet) Sub(that StringSet) StringSet
- func (ss *StringSet) UnmarshalDynamoDBAttributeValue(item *dynamodb.AttributeValue) error
- type Table
- func (t *Table) ConsumedCapacity() ConsumedCapacity
- func (t *Table) CreateTableIfNotExists(ctx context.Context, opts ...TableOption) error
- func (t *Table) DDB() *DDB
- func (t *Table) Delete(hashKey interface{}) *Delete
- func (t *Table) DeleteTableIfExists(ctx context.Context) error
- func (t *Table) Get(hashKey interface{}) *Get
- func (t *Table) Put(v interface{}) *Put
- func (t *Table) Query(expr string, values ...interface{}) *Query
- func (t *Table) Scan() *Scan
- func (t *Table) Update(hashKey interface{}) *Update
- type TableIndexOption
- type TableOption
- type Update
- func (u *Update) Add(expr string, values ...interface{}) *Update
- func (u *Update) Condition(expr string, values ...interface{}) *Update
- func (u *Update) ConsumedCapacity(capture *ConsumedCapacity) *Update
- func (u *Update) Delete(expr string, values ...interface{}) *Update
- func (u *Update) NewValues(v interface{}) *Update
- func (u *Update) OldValues(v interface{}) *Update
- func (u *Update) Range(rangeKey interface{}) *Update
- func (u *Update) Remove(expr string, values ...interface{}) *Update
- func (u *Update) ReturnValuesOnConditionCheckFailure(value string) *Update
- func (u *Update) Run() error
- func (u *Update) RunWithContext(ctx context.Context) error
- func (u *Update) Set(expr string, values ...interface{}) *Update
- func (u *Update) Tx() (*dynamodb.TransactWriteItem, error)
- func (u *Update) UpdateItemInput() (*dynamodb.UpdateItemInput, error)
- type Window
- type WriteTx
Constants ¶
const ( DefaultBillingMode = dynamodb.BillingModeProvisioned DefaultReadCapacity = int64(3) DefaultWriteCapacity = int64(3) )
const ( ErrInvalidFieldName = "InvalidFieldName" ErrItemNotFound = "ItemNotFound" ErrMismatchedValueCount = "MismatchedValueCount" ErrUnableToMarshalItem = "UnableToMarshalItem" )
Variables ¶
This section is empty.
Functions ¶
func IsInvalidFieldNameError ¶
func IsItemNotFoundError ¶
IsItemNotFoundError returns true if any error in the cause change contains the code, ErrItemNotFound
Types ¶
type Change ¶
type Change struct { // The approximate date and time when the stream record was created, in UNIX // epoch time (http://www.epochconverter.com/) format. ApproximateCreationDateTime EpochSeconds `json:"ApproximateCreationDateTime,omitempty"` // Keys for dynamodb modified dynamodb item Keys map[string]*dynamodb.AttributeValue `json:"Keys,omitempty"` // NewImage holds dynamodb item AFTER modification NewImage map[string]*dynamodb.AttributeValue `json:"NewImage,omitempty"` // OldImage holds dynamodb item BEFORE modification OldImage map[string]*dynamodb.AttributeValue `json:"OldImage,omitempty"` // SequenceNumber of stream record SequenceNumber string `json:"SequenceNumber"` // SizeBytes contains size of record SizeBytes int64 `json:"SizeBytes"` // StreamViewType indicates what type of information is being held // https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_StreamSpecification.html StreamViewType string `json:"StreamViewType"` }
Change represents the change performed
type ConsumedCapacity ¶
type ConsumedCapacity struct { ReadUnits int64 WriteUnits int64 // contains filtered or unexported fields }
func (*ConsumedCapacity) CapacityUnits ¶
func (c *ConsumedCapacity) CapacityUnits() float64
type DDB ¶
type DDB struct {
// contains filtered or unexported fields
}
func New ¶
func New(api dynamodbiface.DynamoDBAPI) *DDB
func (*DDB) TransactGetItems ¶
TransactGetItems allows TransactGetItems to be called without a context
func (*DDB) TransactGetItemsWithContext ¶
TransactGetItemsWithContext wraps the get operations using a TransactGetItems
func (*DDB) TransactWriteItems ¶
func (d *DDB) TransactWriteItems(items ...WriteTx) (*dynamodb.TransactWriteItemsOutput, error)
func (*DDB) TransactWriteItemsWithContext ¶
func (d *DDB) TransactWriteItemsWithContext(ctx context.Context, items ...WriteTx) (*dynamodb.TransactWriteItemsOutput, error)
TransactWriteItemsWithContext applies the provided operations in a dynamodb transaction. Subject to the limits of of TransactWriteItems.
func (*DDB) WithTokenFunc ¶
WithTokenFunc allows the generator func for dynamodb transactions to be overwritten
func (*DDB) WithTransactAttempts ¶
WithTransactAttempts overrides the number of times to attempt a Transact before giving up. Defaults to 4
type Delete ¶
type Delete struct {
// contains filtered or unexported fields
}
func (*Delete) ConsumedCapacity ¶
func (d *Delete) ConsumedCapacity(capture *ConsumedCapacity) *Delete
ConsumedCapacity captures consumed capacity to the property provided
func (*Delete) DeleteItemInput ¶
func (d *Delete) DeleteItemInput() (*dynamodb.DeleteItemInput, error)
func (*Delete) ReturnValuesOnConditionCheckFailure ¶
Use ReturnValuesOnConditionCheckFailure to get the item attributes if the Delete condition fails. For ReturnValuesOnConditionCheckFailure, the valid values are: NONE and ALL_OLD.
Only used by Tx()
type EpochSeconds ¶
type EpochSeconds int64
EpochSeconds expresses time in unix seconds
func (EpochSeconds) MarshalJSON ¶
func (e EpochSeconds) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler
func (*EpochSeconds) UnmarshalJSON ¶
func (e *EpochSeconds) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler
type Error ¶
type Error interface { error Cause() error Code() string Keys() (hashKey, rangeKey *dynamodb.AttributeValue) Message() string TableName() string }
Error provides a unified error definition that includes a code and message along with an optional original error.
type Event ¶
type Event struct { // EventSourceARN holds the arn of the resource that generated the record EventSourceARN string `json:"eventSourceARN,omitempty"` // IsFinalInvokeForWindow - indicates if this is the last invocation for the tumbling window. This only occurs once per window period. [Tumbling Window] IsFinalInvokeForWindow bool `json:"isFinalInvokeForWindow,omitempty"` // IsWindowTerminatedEarly - a window ends early only if the state exceeds the maximum allowed size of 1 MB [Tumbling Window] IsWindowTerminatedEarly bool `json:"isWindowTerminatedEarly,omitempty"` // Records contains the modified records in order Records []Record `json:"Records"` // ShardId uniquely identifies the shard ShardId string `json:"shardId,omitempty"` // State holds optional tumbling window state [Tumbling Window] State json.RawMessage `json:"state,omitempty"` // Window holds the endpoints of this window [Tumbling Window] Window *Window `json:"window,omitempty"` }
Event record emitted by dynamodb streams.
Motivation: While github.com/aws/aws-lambda-go is a fantastic library for working with lambda in Go, the dynamodb type defined in the Record cannot be unmarshaled by github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute
type Get ¶
type Get struct {
// contains filtered or unexported fields
}
func (*Get) ConsistentRead ¶
func (*Get) ConsumedCapacity ¶
func (g *Get) ConsumedCapacity(capture *ConsumedCapacity) *Get
ConsumedCapacity captures consumed capacity to the property provided
func (*Get) GetItemInput ¶
func (g *Get) GetItemInput() (*dynamodb.GetItemInput, error)
type GetTx ¶
type GetTx interface { // Decode the response from AWS Decode(v *dynamodb.ItemResponse) error // Tx generates the get input Tx() (*dynamodb.TransactGetItem, error) }
GetTx encapsulates a transactional get operation
type Int64Set ¶
type Int64Set []int64
Int64Set represents an array expressed as a set. (otherwise than a List which would be the default)
func (Int64Set) MarshalDynamoDBAttributeValue ¶
func (ii Int64Set) MarshalDynamoDBAttributeValue(item *dynamodb.AttributeValue) error
MarshalDynamoDBAttributeValue implements Marshaler
func (*Int64Set) UnmarshalDynamoDBAttributeValue ¶
func (ii *Int64Set) UnmarshalDynamoDBAttributeValue(item *dynamodb.AttributeValue) error
UnmarshalDynamoDBAttributeValue implements Unmarshaler
type Item ¶
type Item interface { // Raw returns the raw value of the element Raw() map[string]*dynamodb.AttributeValue // Unmarshal the record into the provided interface Unmarshal(v interface{}) error }
Item provides handle to each record that can be unmarshalled
type Put ¶
type Put struct {
// contains filtered or unexported fields
}
func (*Put) ConsumedCapacity ¶
func (p *Put) ConsumedCapacity(capture *ConsumedCapacity) *Put
ConsumedCapacity captures consumed capacity to the property provided
func (*Put) PutItemInput ¶
func (p *Put) PutItemInput() (*dynamodb.PutItemInput, error)
func (*Put) ReturnValuesOnConditionCheckFailure ¶
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
func (*Query) ConsistentRead ¶
func (*Query) ConsumedCapacity ¶
func (q *Query) ConsumedCapacity(capture *ConsumedCapacity) *Query
ConsumedCapacity captures consumed capacity to the property provided
func (*Query) EachWithContext ¶
func (*Query) FindAllWithContext ¶
FindAllWithContext returns all record using context provided
func (*Query) FirstWithContext ¶
FirstWithContext binds the first value and returns
func (*Query) KeyCondition ¶
func (*Query) LastEvaluatedKey ¶
func (q *Query) LastEvaluatedKey(lastEvaluatedKey *map[string]*dynamodb.AttributeValue) *Query
LastEvaluatedKey stores the last evaluated key into the provided value
func (*Query) LastEvaluatedToken ¶
LastEvaluatedToken stores the last evaluated key as a base64 encoded string
func (*Query) QueryInput ¶
func (q *Query) QueryInput() (*dynamodb.QueryInput, error)
QueryInput returns the raw dynamodb QueryInput that will be submitted
func (*Query) ScanIndexForward ¶
ScanIndexForward when true returns the values in reverse sort key order https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html
func (*Query) StartKey ¶
func (q *Query) StartKey(startKey map[string]*dynamodb.AttributeValue) *Query
StartKey assigns the continuation key used for query pagination
func (*Query) StartToken ¶
StartToken encodes start key as a base64 encoded string
type Record ¶
type Record struct { // AWSRegion update occurred within AWSRegion string `json:"awsRegion"` // Change holds the modification to the dynamodb record Change Change `json:"dynamodb"` // EventID holds a unique identifier for event EventID string `json:"eventID"` // EventName will be one of INSERT, MODIFY, or REMOVE // https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_Record.html EventName string `json:"eventName"` // EventSource for record. Will generally be aws:dynamodb EventSource string `json:"eventSource"` // EventSourceARN holds the arn of the resource that generated the record EventSourceARN string `json:"eventSourceARN"` // EventVersion number of the stream format EventVersion string `json:"eventVersion"` }
Record holds the metadata for the dynamodb change
type Scan ¶
type Scan struct {
// contains filtered or unexported fields
}
Scan encapsulates a scan request
func (*Scan) ConsistentRead ¶
ConsistentRead enables or disables consistent reading
func (*Scan) ConsumedCapacity ¶
func (s *Scan) ConsumedCapacity(capture *ConsumedCapacity) *Scan
ConsumedCapacity captures consumed capacity to the property provided
func (*Scan) Each ¶
Each is identical to EachWithContext except that it does not allow for cancellation via the context.
func (*Scan) EachWithContext ¶
EachWithContext iterates invokes the callback for each record that matches the scan. So long as the callback returns `true, nil`, the scan will continue. If the callback either returns an error OR false, the scan will stop. The scan will also stop if the context has been canceled.
func (*Scan) FirstWithContext ¶
FirstWithContext returns the first scanned record and allows for cancellation
func (*Scan) TotalSegments ¶
TotalSegments allows for the Scan operation to run in parallel. If not set, defaults to 1 segment
type StringSet ¶
type StringSet []string
StringSet represents an array expressed as a set. (otherwise than a List which would be the default)
func (StringSet) ContainsRegexp ¶
ContainsRegexp returns true if regexp matches any element of the Regexp
func (StringSet) MarshalDynamoDBAttributeValue ¶
func (ss StringSet) MarshalDynamoDBAttributeValue(item *dynamodb.AttributeValue) error
MarshalDynamoDBAttributeValue implements Marshaler
func (StringSet) StringSlice ¶
StringSlice returns StringSet as []string
func (StringSet) Sub ¶
Sub returns a new StringSet that contains the original StringSet minus the elements contained in the provided StringSet
func (*StringSet) UnmarshalDynamoDBAttributeValue ¶
func (ss *StringSet) UnmarshalDynamoDBAttributeValue(item *dynamodb.AttributeValue) error
UnmarshalDynamoDBAttributeValue implements Unmarshaler
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) ConsumedCapacity ¶
func (t *Table) ConsumedCapacity() ConsumedCapacity
func (*Table) CreateTableIfNotExists ¶
func (t *Table) CreateTableIfNotExists(ctx context.Context, opts ...TableOption) error
type TableIndexOption ¶
type TableIndexOption interface { TableOption }
func WithReadCapacity ¶
func WithReadCapacity(rcap int64) TableIndexOption
func WithWriteCapacity ¶
func WithWriteCapacity(wcap int64) TableIndexOption
type TableOption ¶
type TableOption interface {
ApplyTable(o *tableOptions)
}
func WithBillingMode ¶
func WithBillingMode(mode string) TableOption
func WithStreamSpecification ¶
func WithStreamSpecification(streamViewType string) TableOption
type Update ¶
type Update struct {
// contains filtered or unexported fields
}
Update encapsulates the UpdateItem action
func (*Update) Condition ¶
Condition applies a condition to the update. When called multiple times, the conditions will be and-ed with each other.
func (*Update) ConsumedCapacity ¶
func (u *Update) ConsumedCapacity(capture *ConsumedCapacity) *Update
func (*Update) ReturnValuesOnConditionCheckFailure ¶
func (*Update) RunWithContext ¶
RunWithContext invokes the update command using the provided context
func (*Update) Tx ¶
func (u *Update) Tx() (*dynamodb.TransactWriteItem, error)
Tx returns *dynamodb.TransactWriteItem suitable for use in a transaction
func (*Update) UpdateItemInput ¶
func (u *Update) UpdateItemInput() (*dynamodb.UpdateItemInput, error)
type Window ¶
Window refers to the tumbling window https://aws.amazon.com/blogs/compute/using-aws-lambda-for-streaming-analytics/
type WriteTx ¶
type WriteTx interface {
Tx() (*dynamodb.TransactWriteItem, error)
}
WriteTx converts ddb operations into instances of *dynamodb.TransactWriteItem