Documentation ¶
Overview ¶
This is an experimental library for use with DynamoDB. It uses github.com/bmizerany/aws4 to sign requests. See Example for use.
Example (CreateAndListTables) ¶
package main import ( "fmt" "github.com/bmizerany/aws4/dydb" "log" ) func init() { log.SetFlags(0) } func main() { var db dydb.DB type AttributeDefinition struct { AttributeName string AttributeType string } type KeySchema struct { AttributeName string KeyType string } var posts struct { TableName string AttributeDefinitions []AttributeDefinition KeySchema []KeySchema ProvisionedThroughput struct { ReadCapacityUnits int WriteCapacityUnits int } } posts.TableName = "Posts" posts.AttributeDefinitions = []AttributeDefinition{{"Slug", "S"}} posts.KeySchema = []KeySchema{{"Slug", "HASH"}} posts.ProvisionedThroughput.ReadCapacityUnits = 4 posts.ProvisionedThroughput.WriteCapacityUnits = 4 if err := db.Exec("CreateTable", posts); err != nil { if !dydb.IsException(err, "ResourceInUseException") { log.Fatal(err) } } var resp struct{ TableNames []string } if err := db.Query("ListTables", nil).Decode(&resp); err != nil { log.Fatal(err) } fmt.Printf("%q", resp.TableNames) }
Output: ["Posts"]
Index ¶
Examples ¶
Constants ¶
View Source
const ( DefaultURL = "https://dynamodb.us-east-1.amazonaws.com/" DefaultVersion = "20120810" )
Variables ¶
This section is empty.
Functions ¶
func IsException ¶
IsException returns true if err is a ResponseError whos TypeName() equals name; false otherwise.
Types ¶
type DB ¶
type DB struct { // The version of DynamoDB to use. If empty string, DefaultVersion is // used. Version string // If nil, aws4.DefaultClient is used. Client *aws4.Client // If empty, DefaultURL is used. URL string }
func (*DB) Exec ¶
Exec is like Query, but discards the response. It returns the error if there was one.
type ResponseError ¶
A ResponseError is returned by Decode when an error communicating with DynamoDB occurs.
func (*ResponseError) Error ¶
func (e *ResponseError) Error() string
func (*ResponseError) TypeName ¶
func (e *ResponseError) TypeName() string
TypeName returns the error Type without the namespace.
Click to show internal directories.
Click to hide internal directories.