dynago

package module
v0.0.0-...-cce0b77 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2016 License: MIT Imports: 8 Imported by: 0

README

dynago

DynamoDB client for Go, now with streams support

Installation

$ go get github.com/raff/dynago

Library Documentation

http://godoc.org/github.com/raff/dynago

Command line tool

Installation
$ go install github.com/raff/dynago/dynagosh
Execution
$ dynagosh
Configuration

Create a file named .dynagorc in the current directory or in your home directory that looks like this:

[dynago]
profile=default_profile_name

[profile "default_profile_name"]
region=us-west-2
accessKey=aws_access_key
secretKey=aws_secret_key

The file should contain two or more sections:

  • One named "dynago" with one entry with name "profile" and value the name of the default profile to use.
  • One or more "profile" section (the name should be [profile "xxx"]) where "xxx" identify the profile name. Each of these sections should have the correct accessKey and secretKey to access your DynamoDB tables and optionally the region (default "us-east-1")
Usage with DynamoDB Local

In order to test against DynamoDB local (the local "test" version of DynamoDB):

  • Download/install and run DynamoDB Local (use this version for streams support).
  • Add an entry in /etc/hosts for a URL that looks like a DynamoDB endpoint (aws4.Sign picks the region from the endpoint URL):
    127.0.0.1 dynamodb.local.amazonaws.com
  • Add a section in .dynagorc for the "local" environment:
    [profile "local"]
    region = http://dynamodb.local.amazonaws.com:8000
    accessKey = AAAAAAAAAAAAAAAAAAAA
    secretKey = xxxxxxxxxxxxxxxxxxxx
  • run dynagosh using the local environment:
    > dynagosh --env=local
Use stream commands
  • Run against DynamoDB Local (streams preview) See previous section
  • Create a table with stream enabled
dynagosh> create message id:S title:S 5 5 new

struct {
  AttributeDefinitions: [
    struct {
      AttributeName: "id",
      AttributeType: "S"
    },
    struct {
      AttributeName: "title",
      AttributeType: "S"
    }
  ],
  CreationDateTime: 2014-11-15 16:47:33 -0800 PST,
  ItemCount: 0,
  KeySchema: [
    struct {
      AttributeName: "id",
      KeyType: "HASH"
    },
    struct {
      AttributeName: "title",
      KeyType: "RANGE"
    }
  ],
  LocalSecondaryIndexes: [
  ],
  ProvisionedThroughput: struct {
    LastDecreaseDateTime: 1969-12-31 16:00:00 -0800 PST,
    LastIncreaseDateTime: 1969-12-31 16:00:00 -0800 PST,
    NumberOfDecreasesToday: 0,
    ReadCapacityUnits: 5,
    WriteCapacityUnits: 5
  },
  TableName: "message",
  TableSizeBytes: 0,
  TableStatus: "ACTIVE",
  StreamSpecification: struct {
    StreamEnabled: true,
    StreamViewType: "NEW_IMAGE"
  }
}
  • List tables
dynagosh> ls

Available tables
   message
  • List streams
dynagosh> lss

Available streams
0 78e731027d8fd50ed642340b7c9a63b314160988539599c66a
  • Add a message
dynagosh> put message "{\"id\":\"1\", \"title\":\"hello\", \"message\":\"hello there\"}"

{
}
consumed: 0
  • Add another message
dynagosh> put message "{\"id\":\"2\", \"title\":\"hi\", \"message\":\"hello agi\"}"
{
}
consumed: 0
  • List stream records
dynagosh> lsr 0

INSERT {
  "id": "1",
  "message": "hello there",
  "title": "hello"
}

INSERT {
  "message": "hello agi",
  "title": "hi",
  "id": "2"
}
  • Verbose stream records
dynagosh> lsr -verbose 0

struct {
  NextShardIterator: "000/NzhlNzMxMDI3ZDhmZDUwZWQ2NDIzNDBiN2M5YTYzYjMxNDE2MDk4ODUzOTU5OWM2NmEvc2hhcmRJZC0wMDAwMDAwMTQxNj
A5ODg1Mzk2Ni0xMmY2NjhkMS8wMDAwMDAwMDAwMDAwMDAwMDAwMDMvMDAwMDAwMDAwMDAwMDAwMDAxNDE2MDk4OTg1Nzg2",
  Records: [
    struct {
      AwsRegion: "ddblocal",
      Dynamodb: struct {
        Keys: {
          "id": "1",
          "title": "hello"
        },
        NewImage: {
          "message": "hello there",
          "title": "hello",
          "id": "1"
        },
        OldImage: {
        },
        SequenceNumber: "000000000000000000001",
        SizeBytes: 44,
        StreamViewType: "NEW_IMAGE"
      },
      EventID: "0c744dd5-737b-42bb-864b-d18d5d5e71af",
      EventName: "INSERT",
      EventSource: "aws:dynamodb",
      EventVersion: "1.0"
    },
    struct {
      AwsRegion: "ddblocal",
      Dynamodb: struct {
        Keys: {
          "title": "hi",
          "id": "2"
        },
        NewImage: {
          "id": "2",
          "message": "hello agi",
          "title": "hi"
        },
        OldImage: {
        },
        SequenceNumber: "000000000000000000002",
        SizeBytes: 36,
        StreamViewType: "NEW_IMAGE"
      },
      EventID: "599e9002-2c73-43e0-80d5-127fd6947ba4",
      EventName: "INSERT",
      EventSource: "aws:dynamodb",
      EventVersion: "1.0"
    }
  ]
}

Documentation

Index

Constants

View Source
const (
	STRING_ATTRIBUTE     = "S"
	STRING_SET_ATTRIBUTE = "SS"
	NUMBER_ATTRIBUTE     = "N"
	NUMBER_SET_ATTRIBUTE = "NS"
	BINARY_ATTRIBUTE     = "B"
	BINARY_SET_ATTRIBUTE = "BS"

	LIST_ATTRIBUTE    = "L"
	MAP_ATTRIBUTE     = "M"
	BOOLEAN_ATTRIBUTE = "BOOL"
	NULL_ATTRIBUTE    = "NULL"
)
View Source
const (
	REGION_US_EAST_1 = "us-east-1"
	REGION_US_WEST_1 = "us-west-1"
	REGION_US_WEST_2 = "us-west-2"

	RETRY_COUNT = 10
)
View Source
const (
	SELECT_ALL        = "ALL_ATTRIBUTES"
	SELECT_PROJECTED  = "ALL_PROJECTED_ATTRIBUTES"
	SELECT_ATTRIBUTES = "SPECIFIC_ATTRIBUTES"
	SELECT_COUNT      = "COUNT"
)
View Source
const (
	AT_SEQUENCE    = "AT_SEQUENCE_NUMBER"
	AFTER_SEQUENCE = "AFTER_SEQUENCE_NUMBER"
	LAST           = "TRIM_HORIZON"
	LATEST         = "LATEST"
)
View Source
const (
	HASH_KEY_TYPE  = "HASH"
	RANGE_KEY_TYPE = "RANGE"

	TABLE_STATUS_CREATING = "CREATING"
	TABLE_STATUS_DELETING = "DELETING"
	TABLE_STATUS_UPDATING = "UPDATING"
	TABLE_STATUS_ACTIVE   = "ACTIVE"

	STREAM_VIEW_NEW  = "NEW_IMAGE"
	STREAM_VIEW_OLD  = "OLD_IMAGE"
	STREAM_VIEW_ALL  = "NEW_AND_OLD_IMAGES"
	STREAM_VIEW_KEYS = "KEYS_ONLY"

	STREAM_VIEW_DISABLED = "NO" // this is NOT a real value, it tells the API to disable streams for the table

)

Variables

View Source
var (
	NO_CONDITION = AttrCondition{}
	NO_VALUE     = []AttributeValue{}
)
View Source
var (
	RETURN_CONSUMED = map[bool]string{/* contains filtered or unexported fields */}

	RETURN_TOTAL_CONSUMED = "TOTAL"
	RETURN_INDEX_CONSUMED = "INDEXED"

	RETURN_METRICS = map[bool]string{/* contains filtered or unexported fields */}

	RETURN_NONE        = "NONE"
	RETURN_ALL_OLD     = "ALL_OLD"
	RETURN_ALL_NEW     = "ALL_NEW"
	RETURN_UPDATED_OLD = "UPDATED_OLD"
	RETURN_UPDATED_NEW = "UPDATED_NEW"
)
View Source
var (
	ERR_MISSING_KEY   = errors.New("hash-key required")
	ERR_TOO_MANY_KEYS = errors.New("too many keys")
	ERR_NOT_FOUND     = errors.New(errorNotFound)
)
View Source
var (
	Regions = map[string]string{
		REGION_US_EAST_1: "https://dynamodb.us-east-1.amazonaws.com/",
		REGION_US_WEST_1: "https://dynamodb.us-west-1.amazonaws.com/",
		REGION_US_WEST_2: "https://dynamodb.us-west-2.amazonaws.com/",
	}
)

Functions

func DecodeItem

func DecodeItem(item AttributeNameValue) map[string]interface{}

func DecodeValue

func DecodeValue(attrValue AttributeValue) interface{}

Types

type AttrCondition

type AttrCondition map[string]Condition

type AttributeDefinition

type AttributeDefinition struct {
	AttributeName string
	AttributeType string
}

func (*AttributeDefinition) BEGINS_WITH

func (attr *AttributeDefinition) BEGINS_WITH(value interface{}) AttrCondition

func (*AttributeDefinition) BETWEEN

func (attr *AttributeDefinition) BETWEEN(value1, value2 interface{}) AttrCondition

func (*AttributeDefinition) CONTAINS

func (attr *AttributeDefinition) CONTAINS(value interface{}) AttrCondition

func (*AttributeDefinition) Condition

func (attr *AttributeDefinition) Condition(op string, values ...interface{}) AttrCondition

func (*AttributeDefinition) EQ

func (attr *AttributeDefinition) EQ(value interface{}) AttrCondition

func (*AttributeDefinition) GE

func (attr *AttributeDefinition) GE(value interface{}) AttrCondition

func (*AttributeDefinition) GT

func (attr *AttributeDefinition) GT(value interface{}) AttrCondition

func (*AttributeDefinition) IN

func (attr *AttributeDefinition) IN(values []interface{}) AttrCondition

func (*AttributeDefinition) LE

func (attr *AttributeDefinition) LE(value interface{}) AttrCondition

func (*AttributeDefinition) LT

func (attr *AttributeDefinition) LT(value interface{}) AttrCondition

func (*AttributeDefinition) NE

func (attr *AttributeDefinition) NE(value interface{}) AttrCondition

func (*AttributeDefinition) NOT_CONTAINS

func (attr *AttributeDefinition) NOT_CONTAINS(value interface{}) AttrCondition

func (*AttributeDefinition) NOT_NULL

func (attr *AttributeDefinition) NOT_NULL() AttrCondition

func (*AttributeDefinition) NULL

func (attr *AttributeDefinition) NULL() AttrCondition

type AttributeNameValue

type AttributeNameValue map[string]AttributeValue

Attributes are encoded as { "name": { "type": "value" } }

func EncodeAttribute

func EncodeAttribute(attr AttributeDefinition, value interface{}) AttributeNameValue

Encode an attribute with its value

func EncodeItem

func EncodeItem(item map[string]interface{}) AttributeNameValue

Encode a user item (map of name/values) into a DynamoDB item

type AttributeValue

type AttributeValue map[string]interface{}

Attribute values are encoded as { "type": "value" }

func EncodeAttributeValue

func EncodeAttributeValue(attr AttributeDefinition, value interface{}) AttributeValue

Encode a value according to the attribute type

func EncodeAttributeValues

func EncodeAttributeValues(attr AttributeDefinition, values ...interface{}) []AttributeValue

func EncodeValue

func EncodeValue(value interface{}) AttributeValue

Encode a value according to its type

type Condition

type Condition struct {
	ComparisonOperator string
	AttributeValueList []AttributeValue
}

func BEGINS_WITH

func BEGINS_WITH(v AttributeValue) Condition

func BETWEEN

func BETWEEN(v1, v2 AttributeValue) Condition

func CONTAINS

func CONTAINS(v AttributeValue) Condition

func EQ

func GE

func GT

func IN

func IN(v []AttributeValue) Condition

func LE

func LT

func MakeCondition

func MakeCondition(op, typ string, values ...string) Condition

func NE

func NOT_CONTAINS

func NOT_CONTAINS(v AttributeValue) Condition

func NOT_NULL

func NOT_NULL() Condition

func NULL

func NULL() Condition

type ConsumedCapacityDescription

type ConsumedCapacityDescription struct {
	CapacityUnits float32
	TableName     string
}

type CreateTableRequest

type CreateTableRequest struct {
	TableName             string
	ProvisionedThroughput ProvisionedThroughputRequest
	AttributeDefinitions  []AttributeDefinition
	KeySchema             []KeySchemaElement
	LocalSecondaryIndexes []LocalSecondaryIndexRequest
	StreamSpecification   StreamSpecification
}

type CreateTableResult

type CreateTableResult struct {
	TableDescription TableDescription
}

type DBClient

type DBClient struct {
	dydb.DB
}

func NewDBClient

func NewDBClient() (db *DBClient)

NewDBClient creates a new DynamoDB client

func (*DBClient) CreateTable

func (db *DBClient) CreateTable(tableName string, attributes []AttributeDefinition, keys []string, rc, wc int, streamView string) (*TableDescription, error)

func (*DBClient) CreateTableInstance

func (db *DBClient) CreateTableInstance(tableName string, attributes []AttributeDefinition, keys []string, rc, wc int, streamView string) (*TableInstance, error)

func (*DBClient) DeleteItem

func (db *DBClient) DeleteItem(tableName string, hashKey *KeyValue, rangeKey *KeyValue, options ...ItemOption) (*Item, float32, error)

func (*DBClient) DeleteTable

func (db *DBClient) DeleteTable(tableName string) (*TableDescription, error)

func (*DBClient) DescribeStream

func (db *DBClient) DescribeStream(streamId string, options ...DescribeStreamOption) (*StreamDescription, error)

func (*DBClient) DescribeTable

func (db *DBClient) DescribeTable(tableName string) (*TableDescription, error)

func (*DBClient) GetItem

func (db *DBClient) GetItem(tableName string, hashKey *KeyValue, rangeKey *KeyValue, attributes []string, consistent bool, consumed bool) (map[string]interface{}, float32, error)

func (*DBClient) GetRecords

func (db *DBClient) GetRecords(shardIterator string, limit int) (*GetRecordsResult, error)

func (*DBClient) GetShardIterator

func (db *DBClient) GetShardIterator(streamId, shardId, shardIteratorType, sequenceNumber string) (string, error)

func (*DBClient) GetTable

func (db *DBClient) GetTable(tableName string) (*TableInstance, error)

func (*DBClient) ListStreams

func (db *DBClient) ListStreams(options ...ListStreamsOption) ([]string, error)

func (*DBClient) ListTables

func (db *DBClient) ListTables() ([]string, error)

func (*DBClient) PutItem

func (db *DBClient) PutItem(tableName string, item Item, options ...ItemOption) (*Item, float32, error)

func (*DBClient) Query

func (db *DBClient) Query(action string, v interface{}) dydb.Decoder

Query executes a DynamoDB query

func (*DBClient) SetCredentials

func (db *DBClient) SetCredentials(accessKey, secretKey string) *DBClient

SetCredentials sets client's credentials. If not set the driver will try to get them from the environment

func (*DBClient) SetRegion

func (db *DBClient) SetRegion(region string) *DBClient

SetRegion sets the URL for a particular region (us-east-1, us-west-1, etc.)

If region looks like an URL it's used as the endpoint URL (and the region is derived from it)

func (*DBClient) SetRegionAndURL

func (db *DBClient) SetRegionAndURL(region, url string) *DBClient

SetRegionAndURL set the region and the endpoint URL

Useful when using non-standard URLs (i.e. DynamoDB Local)

func (*DBClient) UpdateItem

func (db *DBClient) UpdateItem(tableName string, hashKey *KeyValue, rangeKey *KeyValue, updates string, options ...ItemOption) (*Item, float32, error)

func (*DBClient) UpdateTable

func (db *DBClient) UpdateTable(tableName string, rc, wc int, streamView string) (*TableDescription, error)

type DeleteTableRequest

type DeleteTableRequest struct {
	TableName string
}

type DeleteTableResult

type DeleteTableResult struct {
	Table TableDescription
}

type DescribeStreamOption

type DescribeStreamOption func(*DescribeStreamRequest)

func DsLimit

func DsLimit(limit int) DescribeStreamOption

func DsStart

func DsStart(startId string) DescribeStreamOption

type DescribeStreamRequest

type DescribeStreamRequest struct {
	StreamId              string
	Limit                 int    `json:",omitempty"`
	ExclusiveStartShardId string `json:",omitempty"`
}

type DescribeStreamResult

type DescribeStreamResult struct {
	StreamDescription StreamDescription
}

type DescribeTableRequest

type DescribeTableRequest struct {
	TableName string
}

type DescribeTableResult

type DescribeTableResult struct {
	Table TableDescription
}

type EpochTime

type EpochTime struct {
	time.Time
}

func (*EpochTime) UnmarshalJSON

func (t *EpochTime) UnmarshalJSON(data []byte) (err error)

type GetItemRequest

type GetItemRequest struct {
	TableName              string
	Key                    AttributeNameValue
	AttributesToGet        []string `json:",omitempty"`
	ConsistentRead         bool
	ReturnConsumedCapacity string `json:",omitempty"`
}

type GetItemResult

type GetItemResult struct {
	ConsumedCapacity ConsumedCapacityDescription

	Item Item
}

type GetRecordsRequest

type GetRecordsRequest struct {
	ShardIterator string
	Limit         int `json:",omitempty"`
}

type GetRecordsResult

type GetRecordsResult struct {
	NextShardIterator string
	Records           []Record
}

type GetShardIteratorRequest

type GetShardIteratorRequest struct {
	StreamId          string
	ShardId           string
	ShardIteratorType string // TRIM_HORIZON | LATEST | AT_SEQUENCE_NUMBER | AFTER_SEQUENCE_NUMBER
	SequenceNumber    string `json:",omitempty"`
}

type GetShardIteratorResult

type GetShardIteratorResult struct {
	ShardIterator string
}

type Item

type Item map[string]interface{}

Items are maps of name/value pairs

func (*Item) MarshalJSON

func (pi *Item) MarshalJSON() ([]byte, error)

func (*Item) UnmarshalJSON

func (pi *Item) UnmarshalJSON(data []byte) error

type ItemCollectionMetrics

type ItemCollectionMetrics struct {
	ItemCollectionKey   AttributeNameValue
	SizeEstimateRangeGB []float64
}

type ItemOption

type ItemOption func(*ItemRequest)

func ConditionExpression

func ConditionExpression(expr string) ItemOption

func ExpressionAttributeNames

func ExpressionAttributeNames(names map[string]string) ItemOption

func ExpressionAttributeValues

func ExpressionAttributeValues(values map[string]interface{}) ItemOption

func ReturnConsumed

func ReturnConsumed(target string) ItemOption

func ReturnMetrics

func ReturnMetrics(ret bool) ItemOption

func ReturnValues

func ReturnValues(target string) ItemOption

type ItemRequest

type ItemRequest struct {
	TableName string

	Item             *Item              `json:",omitempty"` // PutItem
	Key              AttributeNameValue `json:",omitempty"` // UpdateItem/DeleteItem
	UpdateExpression string             `json:",omitempty"` // UpdateItem

	ConditionExpression       string             `json:",omitempty"`
	ExpressionAttributeNames  map[string]string  `json:",omitempty"`
	ExpressionAttributeValues AttributeNameValue `json:",omitempty"`

	ReturnConsumedCapacity      string `json:",omitempty"` // INDEXED | TOTAL | NONE
	ReturnItemCollectionMetrics string `json:",omitempty"` // SIZE | NONE
	ReturnValues                string `json:",omitempty"` // NONE | ALL_OLD | UPDATED_OLD | ALL_NEW | UPDATED_NEW
}

type ItemResult

type ItemResult struct {
	Attributes            Item
	ConsumedCapacity      ConsumedCapacityDescription
	ItemCollectionMetrics ItemCollectionMetrics
}

type KeySchemaElement

type KeySchemaElement struct {
	AttributeName string
	KeyType       string
}

type KeyValue

type KeyValue struct {
	Key   AttributeDefinition
	Value interface{}
}

type ListStreamsOption

type ListStreamsOption func(*ListStreamsRequest)

func LsLimit

func LsLimit(limit int) ListStreamsOption

func LsStartItem

func LsStartItem(startItem string) ListStreamsOption

func LsTable

func LsTable(tableName string) ListStreamsOption

type ListStreamsRequest

type ListStreamsRequest struct {
	TableName          string `json:",omitempty"`
	Limit              int    `json:",omitempty"`
	ExclusiveStartItem string `json:",omitempty"`
}

type ListStreamsResult

type ListStreamsResult struct {
	LastEvaluatedStreamId string
	StreamIds             []string
}

type ListTablesResult

type ListTablesResult struct {
	TableNames []string
}

type LocalSecondaryIndexDescription

type LocalSecondaryIndexDescription struct {
	IndexName      string
	IndexSizeBytes int64
	ItemCount      int64

	KeySchema  []KeySchemaElement
	Projection ProjectionDescription
}

type LocalSecondaryIndexRequest

type LocalSecondaryIndexRequest struct {
	IndexName  string
	KeySchema  []KeySchemaElement
	Projection ProjectionDescription
}

type ProjectionDescription

type ProjectionDescription struct {
	NonKeyAttributes []string
	ProjectionType   string
}

type ProvisionedThroughputDescription

type ProvisionedThroughputDescription struct {
	LastDecreaseDateTime   EpochTime
	LastIncreaseDateTime   EpochTime
	NumberOfDecreasesToday int
	ReadCapacityUnits      int
	WriteCapacityUnits     int
}

type ProvisionedThroughputRequest

type ProvisionedThroughputRequest struct {
	ReadCapacityUnits  int
	WriteCapacityUnits int
}

type QueryRequest

type QueryRequest struct {
	TableName        string
	AttributesToGet  []string `json:",omitempty"` // deprecated
	ScanIndexForward bool

	ExclusiveStartKey AttributeNameValue   `json:",omitempty"`
	KeyConditions     map[string]Condition `json:",omitempty"` // deprecated
	IndexName         string               `json:",omitempty"`

	KeyConditionExpression    string             `json:",omitempty"`
	FilterExpression          string             `json:",omitempty"`
	ProjectionExpression      string             `json:",omitempty"`
	ExpressionAttributeNames  map[string]string  `json:",omitempty"`
	ExpressionAttributeValues AttributeNameValue `json:",omitempty"`

	Limit                  *int   `json:",omitempty"`
	Select                 string `json:",omitempty"`
	ReturnConsumedCapacity string `json:",omitempty"`
	// contains filtered or unexported fields
}

func Query

func Query(tableName string) *QueryRequest

func QueryTable

func QueryTable(table *TableInstance) *QueryRequest

func (*QueryRequest) Exec

func (req *QueryRequest) Exec(db *DBClient) ([]Item, AttributeNameValue, float32, error)

func (*QueryRequest) SetAttrCondition

func (req *QueryRequest) SetAttrCondition(cond AttrCondition) *QueryRequest

deprecated

func (*QueryRequest) SetAttributeNames

func (req *QueryRequest) SetAttributeNames(names map[string]string) *QueryRequest

func (*QueryRequest) SetAttributeValues

func (req *QueryRequest) SetAttributeValues(values map[string]interface{}) *QueryRequest

func (*QueryRequest) SetAttributes

func (req *QueryRequest) SetAttributes(attributes []string) *QueryRequest

deprecated

func (*QueryRequest) SetCondition

func (req *QueryRequest) SetCondition(attrName string, condition Condition) *QueryRequest

deprecated

func (*QueryRequest) SetConditionExpression

func (req *QueryRequest) SetConditionExpression(cond string) *QueryRequest

func (*QueryRequest) SetConsumed

func (req *QueryRequest) SetConsumed(consumed bool) *QueryRequest

func (*QueryRequest) SetFilterExpression

func (req *QueryRequest) SetFilterExpression(filter string) *QueryRequest

func (*QueryRequest) SetIndex

func (req *QueryRequest) SetIndex(indexName string) *QueryRequest

func (*QueryRequest) SetLimit

func (req *QueryRequest) SetLimit(limit int) *QueryRequest

func (*QueryRequest) SetProjectionExpression

func (req *QueryRequest) SetProjectionExpression(proj string) *QueryRequest

func (*QueryRequest) SetSelect

func (req *QueryRequest) SetSelect(selectValue string) *QueryRequest

func (*QueryRequest) SetStartKey

func (req *QueryRequest) SetStartKey(startKey AttributeNameValue) *QueryRequest

type QueryResult

type QueryResult struct {
	Items            []Item
	ConsumedCapacity ConsumedCapacityDescription
	LastEvaluatedKey AttributeNameValue
	Count            int
	ScannedCount     int
}

type Record

type Record struct {
	AwsRegion    string       `json:"awsRegion"`
	Dynamodb     StreamRecord `json:"dynamodb"`
	EventID      string       `json:"eventID"`
	EventName    string       `json:"eventName"`
	EventSource  string       `json:"eventSource"`
	EventVersion string       `json:"eventVersion"`
}

type ScanRequest

type ScanRequest struct {
	TableName string
	//AttributesToGet   []string    // use ProjectionExpression instead
	ExclusiveStartKey AttributeNameValue

	FilterExpression          string             `json:",omitempty"`
	ProjectionExpression      string             `json:",omitempty"`
	ExpressionAttributeNames  map[string]string  `json:",omitempty"`
	ExpressionAttributeValues AttributeNameValue `json:",omitempty"`

	Limit                  *int   `json:",omitempty"`
	Segment                *int   `json:",omitempty"`
	TotalSegments          *int   `json:",omitempty"`
	Select                 string `json:",omitempty"`
	ReturnConsumedCapacity string `json:",omitempty"`
	// contains filtered or unexported fields
}

func Scan

func Scan(tableName string) *ScanRequest

func ScanTable

func ScanTable(table *TableInstance) *ScanRequest

func (*ScanRequest) Count

func (req *ScanRequest) Count(db *DBClient) (count int, scount int, consumed float32, err error)

func (*ScanRequest) CountWithDelay

func (req *ScanRequest) CountWithDelay(db *DBClient, delay time.Duration) (count int, scount int, consumed float32, err error)

func (*ScanRequest) Exec

func (req *ScanRequest) Exec(db *DBClient) ([]Item, AttributeNameValue, float32, error)

func (*ScanRequest) SetAttributeNames

func (req *ScanRequest) SetAttributeNames(names map[string]string) *ScanRequest

func (*ScanRequest) SetAttributeValues

func (req *ScanRequest) SetAttributeValues(values map[string]interface{}) *ScanRequest

func (*ScanRequest) SetConsumed

func (req *ScanRequest) SetConsumed(consumed bool) *ScanRequest

func (*ScanRequest) SetFilterExpression

func (req *ScanRequest) SetFilterExpression(filter string) *ScanRequest

func (*ScanRequest) SetLimit

func (req *ScanRequest) SetLimit(limit int) *ScanRequest

func (*ScanRequest) SetProjectionExpression

func (req *ScanRequest) SetProjectionExpression(proj string) *ScanRequest

func (*ScanRequest) SetSegment

func (req *ScanRequest) SetSegment(segment, totalSegments int) *ScanRequest

func (*ScanRequest) SetSelect

func (req *ScanRequest) SetSelect(selectValue string) *ScanRequest

func (*ScanRequest) SetStartKey

func (req *ScanRequest) SetStartKey(startKey AttributeNameValue) *ScanRequest

type SequenceNumberRange

type SequenceNumberRange struct {
	StartingSequenceNumber string
	EndingSequenceNumber   string
}

type ShardDescription

type ShardDescription struct {
	ShardId             string
	ParentShardId       string
	SequenceNumberRange SequenceNumberRange
}

type StreamDescription

type StreamDescription struct {
	TableName               string
	KeySchema               []KeySchemaElement
	CreationRequestDateTime EpochTime
	StreamARN               string
	StreamId                string
	StreamStatus            string
	StreamViewType          string
	LastEvaluatedShardId    string
	Shards                  []ShardDescription
}

type StreamRecord

type StreamRecord struct {
	Keys           Item
	NewImage       Item
	OldImage       Item
	SequenceNumber string
	SizeBytes      int64
	StreamViewType string
}

type StreamSpecification

type StreamSpecification struct {
	StreamEnabled  bool
	StreamViewType string `json:",omitempty"`
}

type TableDescription

type TableDescription struct {
	AttributeDefinitions []AttributeDefinition

	CreationDateTime EpochTime
	ItemCount        int64

	KeySchema             []KeySchemaElement
	LocalSecondaryIndexes []LocalSecondaryIndexDescription
	ProvisionedThroughput ProvisionedThroughputDescription

	TableName      string
	TableSizeBytes int64
	TableStatus    string

	StreamSpecification StreamSpecification
}

type TableInstance

type TableInstance struct {
	DB   *DBClient
	Name string
	Keys map[string]*AttributeDefinition
}

func (*TableInstance) DeleteItem

func (table *TableInstance) DeleteItem(hashKey interface{}, rangeKey interface{}, options ...ItemOption) (*Item, float32, error)

func (*TableInstance) GetItem

func (table *TableInstance) GetItem(hashKey interface{}, rangeKey interface{}, attributes []string, consistent bool, consumed bool) (map[string]interface{}, float32, error)

func (*TableInstance) HashKey

func (table *TableInstance) HashKey() *AttributeDefinition

func (*TableInstance) HashRange

func (table *TableInstance) HashRange() bool

HashRange returns true if this table requires hash and range key

func (*TableInstance) PutItem

func (table *TableInstance) PutItem(item Item, options ...ItemOption) (*Item, float32, error)

func (*TableInstance) Query

func (table *TableInstance) Query(hashKey interface{}) *QueryRequest

func (*TableInstance) RangeKey

func (table *TableInstance) RangeKey() *AttributeDefinition

func (*TableInstance) UpdateItem

func (table *TableInstance) UpdateItem(hashKey interface{}, rangeKey interface{}, updates string, options ...ItemOption) (*Item, float32, error)

type UpdateTableRequest

type UpdateTableRequest struct {
	TableName string

	ProvisionedThroughput *ProvisionedThroughputRequest `json:",omitempty"`
	StreamSpecification   *StreamSpecification          `json:",omitempty"`
}

type UpdateTableResult

type UpdateTableResult struct {
	TableDescription TableDescription
}

Directories

Path Synopsis
An interactive shell for DynamoDB
An interactive shell for DynamoDB

Jump to

Keyboard shortcuts

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