sdb

package
v0.0.0-...-db1d7af Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2014 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package sdb contains a simple client for Amazon SimpleDB. Only the most basic of operations are supported.

See here for more info:

http://aws.amazon.com/simpledb/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Name  string
	Value string
}

An attribute is a (name, value) pair possessed by an item. Items contain sets of attributes; they may contain multiple attributes with the same name, but not with the same (name, value) pair.

Attribute names and values share the same restrictions as those on item names.

type BatchDeleteMap

type BatchDeleteMap map[ItemName][]DeleteUpdate

A map from item names to delete updates that should be applied to those items. A nil slice indicates that all of the item's attributes should be deleted.

type BatchPutMap

type BatchPutMap map[ItemName][]PutUpdate

A map from item names to updates that should be applied to those items.

type DeleteUpdate

type DeleteUpdate struct {
	// The name of the attribute.
	Name string

	// The particular value of the attribute to delete, if non-nil. Otherwise,
	// all values for the given name will be deleted.
	Value *string
}

An update to make to a particular attribute as part of a Delete request.

type Domain

type Domain interface {
	// Return the name of this domain.
	Name() string

	// Return the database connection to which this domain is attached.
	Db() SimpleDB

	// Atomically apply the supplied updates to the attributes of the named item,
	// but only if the supplied precondition holds. If no precondition is
	// desired, pass nil.
	//
	// The length of updates must be in [1, 256].
	PutAttributes(
		item ItemName,
		updates []PutUpdate,
		precondition *Precondition) error

	// Atomically apply updates to multiple items simultaneously.
	//
	// The length of the map must be in [1, 25]. The length of each of its values
	// must be in [1, 256]. An error may be returned if the underlying request to
	// SimpleDB is too large.
	BatchPutAttributes(updateMap BatchPutMap) error

	// Retrieve a set of attributes for the named item, or all attributes if the
	// attribute name slice is empty.
	//
	// If the named item doesn't exist, the empty set is returned.
	//
	// constistentRead specifies whether completely fresh data is needed or not.
	GetAttributes(
		item ItemName,
		constistentRead bool,
		attrNames []string) (attrs []Attribute, err error)

	// Atomically delete attributes from the named item, but only if the supplied
	// precondition holds. If no precondition is desired, pass nil.
	//
	// If deletes is empty, delete all attributes from the item. Otherwise
	// perform only the deletes is specifies. Deleting a non-existent attribute
	// does not result in an error.
	DeleteAttributes(
		item ItemName,
		deletes []DeleteUpdate,
		precondition *Precondition) error

	// Atomically delete attributes from multiple items simultaneously.
	//
	// If no updates are supplied for a particular item, delete all of its
	// attributes.
	BatchDeleteAttributes(deleteMap BatchDeleteMap) error
}

A domain represents a named domain within the SimpleDB service. It is a collection of named items, each of which possesses a set of attributes.

type ItemName

type ItemName string

The name of an item within a SimpleDB domain. Item names must be UTF-8 strings no longer than 1024 bytes. They must contain only characters that are valid in XML 1.0 documents, as defined by Section 2.2 of the XML 1.0 spec. (Note that this is a more restrictive condition than imposed by SimpleDB itself, and is done for the sake of Go's XML 1.0 parser.)

For more info:

http://goo.gl/Fkjnz
http://goo.gl/csem8

type Precondition

type Precondition struct {
	// The name of the attribute to be inspected. Attributes with multiple values
	// are not supported.
	Name string

	// If non-nil, the value that the attribute must possess at the time of the
	// update. If nil, the attribute must not exist at the time of the update.
	Value *string
}

A precondition for a conditional Put or Delete operation. Preconditions may specify a value that an attribute must have or that the attribute must not exist.

type PutUpdate

type PutUpdate struct {
	// The name of the attribute.
	Name string

	// The value to set for the attribute.
	Value string

	// If true, add this (name, value) attribute rather than replacing any
	// existing attributes with the given name (the default).
	Add bool
}

An update to make to a particular attribute as part of a Put request.

type Region

type Region string

Region represents a regional endpoint to SimpleDB. Domains created within one region are entirely independent of those created in others. You should use one of the region constants defined by this package when referring to regions.

See here for more info:

http://goo.gl/BkF9n
const (
	RegionUsEastNorthernVirginia Region = "sdb.amazonaws.com"
	RegionUsWestOregon           Region = "sdb.us-west-2.amazonaws.com"
	RegionUsWestNorCal           Region = "sdb.us-west-1.amazonaws.com"
	RegionEuIreland              Region = "sdb.eu-west-1.amazonaws.com"
	RegionApacSingapore          Region = "sdb.ap-southeast-1.amazonaws.com"
	RegionApacSydney             Region = "sdb.ap-southeast-2.amazonaws.com"
	RegionApacTokyo              Region = "sdb.ap-northeast-1.amazonaws.com"
	RegionSouthAmericaSaoPaulo   Region = "sdb.sa-east-1.amazonaws.com"
)

type SelectedItem

type SelectedItem struct {
	Name       ItemName
	Attributes []Attribute
}

A single result from a Select operation.

type SimpleDB

type SimpleDB interface {
	// Ensure that the domain with the specified name exists, then return it.
	OpenDomain(name string) (Domain, error)

	// Remove the supplied domain from the DB. Any domains previously opened with
	// this domain's name will no longer be valid. It is not an error to call
	// this method for a domain that has already been deleted.
	DeleteDomain(d Domain) error

	// Retrieve a set of items and their attributes based on a query string.
	//
	// constistentRead specifies whether completely fresh data is needed or not.
	//
	// If the selected result set is too large, a "next token" will be returned.
	// It can be passed to the Select method to resume where the previous result
	// set left off. For the initial query, use nil.
	//
	// For more info:
	//
	//     http://goo.gl/GTsSZ
	//
	Select(
		query string,
		constistentRead bool,
		nextToken []byte) (results []SelectedItem, tok []byte, err error)
}

SimpleDB represents an authenticated connection to a particular endpoint the SimpleDB service.

func NewSimpleDB

func NewSimpleDB(region Region, key aws.AccessKey) (db SimpleDB, err error)

Return a SimpleDB connection tied to the given region, using the sipplied access key to authenticate requests.

Directories

Path Synopsis
Package conn contains code useful for making requests to the SimpleDB servers.
Package conn contains code useful for making requests to the SimpleDB servers.

Jump to

Keyboard shortcuts

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