dynamodb

package
v0.0.0-...-5fcdc93 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2015 License: LGPL-3.0 Imports: 17 Imported by: 0

README

Running integration tests

against DynamoDB local

To download and launch DynamoDB local:

$ make

To test:

$ go test -v -amazon

against real DynamoDB server on us-east

WARNING: Some dangerous operations such as DeleteTable will be performed during the tests. Please be careful.

To test:

$ go test -v -amazon -local=false

Note: Running tests against real DynamoDB will take several minutes.

Documentation

Index

Constants

View Source
const (
	TYPE_BOOLEAN = "BOOL"
	TYPE_STRING  = "S"
	TYPE_NUMBER  = "N"
	TYPE_BINARY  = "B"

	TYPE_LIST = "L"
	TYPE_MAP  = "M"

	TYPE_STRING_SET = "SS"
	TYPE_NUMBER_SET = "NS"
	TYPE_BINARY_SET = "BS"

	COMPARISON_EQUAL                    = "EQ"
	COMPARISON_NOT_EQUAL                = "NE"
	COMPARISON_LESS_THAN_OR_EQUAL       = "LE"
	COMPARISON_LESS_THAN                = "LT"
	COMPARISON_GREATER_THAN_OR_EQUAL    = "GE"
	COMPARISON_GREATER_THAN             = "GT"
	COMPARISON_ATTRIBUTE_EXISTS         = "NOT_NULL"
	COMPARISON_ATTRIBUTE_DOES_NOT_EXIST = "NULL"
	COMPARISON_CONTAINS                 = "CONTAINS"
	COMPARISON_DOES_NOT_CONTAIN         = "NOT_CONTAINS"
	COMPARISON_BEGINS_WITH              = "BEGINS_WITH"
	COMPARISON_IN                       = "IN"
	COMPARISON_BETWEEN                  = "BETWEEN"
)

Variables

View Source
var DefaultBasicRetry = BasicRetry{}
View Source
var DefaultSkipRetry = SkipRetry{}
View Source
var ErrNotFound = errors.New("Item not found")

Specific error constants

Functions

func RunQuery

func RunQuery(q *Query, t *Table) ([]map[string]*Attribute, error)

func UnmarshalAttributes

func UnmarshalAttributes(attributesRef *map[string]*Attribute, m interface{}) error

Types

type Attribute

type Attribute struct {
	Type      string
	Name      string
	Value     string
	SetValues []string
	Exists    string // exists on dynamodb? Values: "true", "false", or ""
}

func MarshalAttributes

func MarshalAttributes(m interface{}) ([]Attribute, error)

func NewBinaryAttribute

func NewBinaryAttribute(name string, value string) *Attribute

func NewBinarySetAttribute

func NewBinarySetAttribute(name string, values []string) *Attribute

func NewNumericAttribute

func NewNumericAttribute(name string, value string) *Attribute

func NewNumericSetAttribute

func NewNumericSetAttribute(name string, values []string) *Attribute

func NewStringAttribute

func NewStringAttribute(name string, value string) *Attribute

func NewStringSetAttribute

func NewStringSetAttribute(name string, values []string) *Attribute

func (*Attribute) SetExists

func (a *Attribute) SetExists(exists bool) *Attribute

func (*Attribute) SetType

func (a *Attribute) SetType() bool

type AttributeComparison

type AttributeComparison struct {
	AttributeName      string
	ComparisonOperator string
	AttributeValueList []Attribute // contains attributes with only types and names (value ignored)
}

func NewBinaryAttributeComparison

func NewBinaryAttributeComparison(attributeName string, comparisonOperator string, value bool) *AttributeComparison

func NewEqualInt64AttributeComparison

func NewEqualInt64AttributeComparison(attributeName string, equalToValue int64) *AttributeComparison

func NewEqualStringAttributeComparison

func NewEqualStringAttributeComparison(attributeName string, equalToValue string) *AttributeComparison

func NewNumericAttributeComparison

func NewNumericAttributeComparison(attributeName string, comparisonOperator string, value int64) *AttributeComparison

func NewStringAttributeComparison

func NewStringAttributeComparison(attributeName string, comparisonOperator string, value string) *AttributeComparison

type AttributeDefinitionT

type AttributeDefinitionT struct {
	Name string `json:"AttributeName"`
	Type string `json:"AttributeType"`
}

func (*AttributeDefinitionT) GetEmptyAttribute

func (a *AttributeDefinitionT) GetEmptyAttribute() *Attribute

type BasicRetry

type BasicRetry struct{}

func (BasicRetry) Retry

func (br BasicRetry) Retry(exec func() error) error

type BatchGetItem

type BatchGetItem struct {
	Server *Server
	Keys   map[*Table][]Key
}

func (*BatchGetItem) AddTable

func (batchGetItem *BatchGetItem) AddTable(t *Table, keys *[]Key) *BatchGetItem

func (*BatchGetItem) Execute

func (batchGetItem *BatchGetItem) Execute() (map[string][]map[string]*Attribute, error)

type BatchWriteItem

type BatchWriteItem struct {
	Server      *Server
	ItemActions map[*Table]map[string][][]Attribute
}

func (*BatchWriteItem) AddTable

func (batchWriteItem *BatchWriteItem) AddTable(t *Table, itemActions *map[string][][]Attribute) *BatchWriteItem

func (*BatchWriteItem) Execute

func (batchWriteItem *BatchWriteItem) Execute() (map[string]interface{}, error)

type Error

type Error struct {
	StatusCode int // HTTP status code (200, 403, ...)
	Status     string
	Code       string // Dynamodb error code ("MalformedQueryString", ...)
	Message    string // The human-oriented error message
}

Error represents an error in an operation with Dynamodb (following goamz/s3)

func (Error) Error

func (e Error) Error() string

type ExpressionAttributeName

type ExpressionAttributeName struct {
	Name  string
	Value string
}

func NewExpressionAttributeName

func NewExpressionAttributeName(aname, avalue string) *ExpressionAttributeName

type ExpressionAttributeValue

type ExpressionAttributeValue struct {
	Name  string
	Type  string
	Value interface{}
}

func NewExpressionAttributeValue

func NewExpressionAttributeValue(aname, atype string, avalue interface{}) *ExpressionAttributeValue

type GlobalSecondaryIndexT

type GlobalSecondaryIndexT struct {
	IndexName             string
	IndexSizeBytes        int64
	ItemCount             int64
	KeySchema             []KeySchemaT
	Projection            ProjectionT
	ProvisionedThroughput ProvisionedThroughputT
}

type Key

type Key struct {
	HashKey  string
	RangeKey string
}

type KeySchemaT

type KeySchemaT struct {
	AttributeName string
	KeyType       string
}

type LocalSecondaryIndexT

type LocalSecondaryIndexT struct {
	IndexName      string
	IndexSizeBytes int64
	ItemCount      int64
	KeySchema      []KeySchemaT
	Projection     ProjectionT
}

type PrimaryKey

type PrimaryKey struct {
	KeyAttribute   *Attribute
	RangeAttribute *Attribute
}

func (*PrimaryKey) Clone

func (k *PrimaryKey) Clone(h string, r string) []Attribute

Useful when you may have many goroutines using a primary key, so they don't fuxor up your values.

func (*PrimaryKey) HasRange

func (k *PrimaryKey) HasRange() bool

type ProjectionT

type ProjectionT struct {
	ProjectionType   string
	NonKeyAttributes []string
}

type ProvisionedThroughputT

type ProvisionedThroughputT struct {
	NumberOfDecreasesToday int64
	ReadCapacityUnits      int64
	WriteCapacityUnits     int64
}

type Query

type Query struct {
	// contains filtered or unexported fields
}

func NewEmptyQuery

func NewEmptyQuery() *Query

func NewQuery

func NewQuery(t *Table) *Query

func (*Query) AddAttributesToGet

func (q *Query) AddAttributesToGet(attributes []string)

func (*Query) AddConditionExpression

func (q *Query) AddConditionExpression(expression string)

func (*Query) AddCreateRequestTable

func (q *Query) AddCreateRequestTable(description TableDescriptionT)

func (*Query) AddDeleteRequestTable

func (q *Query) AddDeleteRequestTable(description TableDescriptionT)

func (*Query) AddExclusiveStartKey

func (q *Query) AddExclusiveStartKey(t *Table, key *Key)

func (*Query) AddExclusiveStartTableName

func (q *Query) AddExclusiveStartTableName(table string)

func (*Query) AddExpected

func (q *Query) AddExpected(attributes []Attribute)

func (*Query) AddExpressionAttributeNames

func (q *Query) AddExpressionAttributeNames(attrs []ExpressionAttributeName)

func (*Query) AddExpressionAttributeValues

func (q *Query) AddExpressionAttributeValues(attrs []ExpressionAttributeValue)

func (*Query) AddGetRequestItems

func (q *Query) AddGetRequestItems(tableKeys map[*Table][]Key)

func (*Query) AddIndex

func (q *Query) AddIndex(value string)

func (*Query) AddItem

func (q *Query) AddItem(attributes []Attribute)

The primary key must be included in attributes.

func (*Query) AddKey

func (q *Query) AddKey(t *Table, key *Key)

This way of specifing the key is used when doing a Get. If rangeKey is "", it is assumed to not want to be used

func (*Query) AddKeyConditions

func (q *Query) AddKeyConditions(comparisons []AttributeComparison)

func (*Query) AddLimit

func (q *Query) AddLimit(limit int64)

func (*Query) AddParallelScanConfiguration

func (q *Query) AddParallelScanConfiguration(segment int, totalSegments int)

func (*Query) AddQueryFilter

func (q *Query) AddQueryFilter(comparisons []AttributeComparison)

func (*Query) AddScanFilter

func (q *Query) AddScanFilter(comparisons []AttributeComparison)
"ScanFilter":{
    "AttributeName1":{"AttributeValueList":[{"S":"AttributeValue"}],"ComparisonOperator":"EQ"}
},

func (*Query) AddScanIndexForward

func (q *Query) AddScanIndexForward(val bool)

func (*Query) AddSelect

func (q *Query) AddSelect(value string)

func (*Query) AddUpdateExpression

func (q *Query) AddUpdateExpression(update string)

func (*Query) AddUpdateRequestTable

func (q *Query) AddUpdateRequestTable(description TableDescriptionT)

func (*Query) AddUpdates

func (q *Query) AddUpdates(attributes []Attribute, action string)

func (*Query) AddWriteRequestItems

func (q *Query) AddWriteRequestItems(tableItems map[*Table]map[string][][]Attribute)

func (*Query) ConsistentRead

func (q *Query) ConsistentRead(c bool)

func (*Query) String

func (q *Query) String() string

type RetryHandlerInterface

type RetryHandlerInterface interface {
	Retry(exec func() error) error
}

type Server

type Server struct {
	Auth   aws.Auth
	Region aws.Region
	// contains filtered or unexported fields
}

func New

func New(auth aws.Auth, region aws.Region) *Server

func (*Server) CreateTable

func (s *Server) CreateTable(tableDescription TableDescriptionT) (string, error)

func (*Server) DeleteTable

func (s *Server) DeleteTable(tableDescription TableDescriptionT) (string, error)

func (*Server) DescribeTable

func (s *Server) DescribeTable(name string) (*TableDescriptionT, error)

func (*Server) ListTables

func (s *Server) ListTables() ([]string, error)

func (*Server) ListTablesCallbackIterator

func (s *Server) ListTablesCallbackIterator(cb func(string)) error

func (*Server) NewTable

func (s *Server) NewTable(name string, key PrimaryKey) *Table

func (*Server) SetHttpClient

func (s *Server) SetHttpClient(client *http.Client)

func (*Server) UpdateTable

func (s *Server) UpdateTable(tableDescription TableDescriptionT) (string, error)

type SkipRetry

type SkipRetry struct{}

func (SkipRetry) Retry

func (sr SkipRetry) Retry(exec func() error) error

type Table

type Table struct {
	Server       *Server
	Name         string
	Key          PrimaryKey
	RetryHandler RetryHandlerInterface
}

func (*Table) AddAttributes

func (t *Table) AddAttributes(key *Key, attributes []Attribute) (bool, error)

func (*Table) BatchGetItems

func (t *Table) BatchGetItems(keys []Key) *BatchGetItem

func (*Table) BatchWriteItems

func (t *Table) BatchWriteItems(itemActions map[string][][]Attribute) *BatchWriteItem

func (*Table) ConditionExpressionUpdateAttributes

func (t *Table) ConditionExpressionUpdateAttributes(key *Key,
	update, condition string,
	exprNames []ExpressionAttributeName, exprValues []ExpressionAttributeValue) (bool, error)

func (*Table) ConditionalAddAttributes

func (t *Table) ConditionalAddAttributes(key *Key, attributes, expected []Attribute) (bool, error)

func (*Table) ConditionalDeleteAttributes

func (t *Table) ConditionalDeleteAttributes(key *Key, attributes, expected []Attribute) (bool, error)

func (*Table) ConditionalDeleteItem

func (t *Table) ConditionalDeleteItem(key *Key, expected []Attribute) (bool, error)

func (*Table) ConditionalPutItem

func (t *Table) ConditionalPutItem(hashKey, rangeKey string, attributes, expected []Attribute) (bool, error)

func (*Table) ConditionalUpdateAttributes

func (t *Table) ConditionalUpdateAttributes(key *Key, attributes, expected []Attribute) (bool, error)

func (*Table) CountQuery

func (t *Table) CountQuery(attributeComparisons []AttributeComparison) (int64, error)

func (*Table) DeleteAttributes

func (t *Table) DeleteAttributes(key *Key, attributes []Attribute) (bool, error)

func (*Table) DeleteItem

func (t *Table) DeleteItem(key *Key) (bool, error)

func (*Table) DescribeTable

func (t *Table) DescribeTable() (*TableDescriptionT, error)

func (*Table) FetchPartialResults

func (t *Table) FetchPartialResults(query *Query) ([]map[string]*Attribute, *Key, error)

func (*Table) FetchResultCallbackIterator

func (t *Table) FetchResultCallbackIterator(query *Query, cb func(map[string]*Attribute) error) error

func (*Table) FetchResults

func (t *Table) FetchResults(query *Query) ([]map[string]*Attribute, error)

func (*Table) GetItem

func (t *Table) GetItem(key *Key) (map[string]*Attribute, error)

func (*Table) GetItemConsistent

func (t *Table) GetItemConsistent(key *Key, consistentRead bool) (map[string]*Attribute, error)

func (*Table) LimitedQuery

func (t *Table) LimitedQuery(attributeComparisons []AttributeComparison, limit int64) ([]map[string]*Attribute, error)

func (*Table) LimitedQueryOnIndex

func (t *Table) LimitedQueryOnIndex(attributeComparisons []AttributeComparison, indexName string, limit int64) ([]map[string]*Attribute, error)

func (*Table) ParallelScan

func (t *Table) ParallelScan(attributeComparisons []AttributeComparison, segment int, totalSegments int) ([]map[string]*Attribute, error)

func (*Table) ParallelScanPartial

func (t *Table) ParallelScanPartial(attributeComparisons []AttributeComparison, exclusiveStartKey *Key, segment, totalSegments int) ([]map[string]*Attribute, *Key, error)

func (*Table) ParallelScanPartialLimit

func (t *Table) ParallelScanPartialLimit(attributeComparisons []AttributeComparison, exclusiveStartKey *Key, segment, totalSegments int, limit int64) ([]map[string]*Attribute, *Key, error)

func (*Table) PutItem

func (t *Table) PutItem(hashKey string, rangeKey string, attributes []Attribute) (bool, error)

func (*Table) Query

func (t *Table) Query(attributeComparisons []AttributeComparison) ([]map[string]*Attribute, error)

func (*Table) QueryOnIndex

func (t *Table) QueryOnIndex(attributeComparisons []AttributeComparison, indexName string) ([]map[string]*Attribute, error)

func (*Table) QueryTable

func (t *Table) QueryTable(q *Query) ([]map[string]*Attribute, *Key, error)

func (*Table) Scan

func (t *Table) Scan(attributeComparisons []AttributeComparison) ([]map[string]*Attribute, error)

func (*Table) ScanCallbackIterator

func (t *Table) ScanCallbackIterator(attributeComparisons []AttributeComparison, cb func(map[string]*Attribute) error) error

func (*Table) ScanPartial

func (t *Table) ScanPartial(attributeComparisons []AttributeComparison, exclusiveStartKey *Key) ([]map[string]*Attribute, *Key, error)

func (*Table) ScanPartialLimit

func (t *Table) ScanPartialLimit(attributeComparisons []AttributeComparison, exclusiveStartKey *Key, limit int64) ([]map[string]*Attribute, *Key, error)

func (*Table) SetRetryHandler

func (t *Table) SetRetryHandler(rhi RetryHandlerInterface)

func (*Table) UpdateAttributes

func (t *Table) UpdateAttributes(key *Key, attributes []Attribute) (bool, error)

type TableDescriptionT

type TableDescriptionT struct {
	AttributeDefinitions   []AttributeDefinitionT
	CreationDateTime       float64
	ItemCount              int64
	KeySchema              []KeySchemaT
	LocalSecondaryIndexes  []LocalSecondaryIndexT
	GlobalSecondaryIndexes []GlobalSecondaryIndexT
	ProvisionedThroughput  ProvisionedThroughputT
	TableName              string
	TableSizeBytes         int64
	TableStatus            string
}

func (*TableDescriptionT) BuildPrimaryKey

func (t *TableDescriptionT) BuildPrimaryKey() (pk PrimaryKey, err error)

Jump to

Keyboard shortcuts

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