dynamodocstore

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package dynamodocstore provides a docstore implementation backed by AWS DynamoDB. Use OpenCollection to construct a *docstore.Collection.

URLs

For docstore.OpenCollection, dynamodocstore registers for the scheme "dynamodb". The default URL opener will use an AWS session with the default credentials and configuration; see https://docs.aws.amazon.com/sdk-for-go/api/aws/session/ for more details. To customize the URL opener, or for more details on the URL format, see URLOpener. See https://godoc.org/gocloud.dev#hdr-URLs for background information.

Example
package main

import (
	"context"
	"fmt"

	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/dynamodb"
	"gocloud.dev/internal/docstore/dynamodocstore"
)

func main() {
	ctx := context.Background()
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println(err)
		return
	}
	coll, err := dynamodocstore.OpenCollection(dynamodb.New(sess), "docstore-test", "_id", "")
	if err != nil {
		fmt.Println(err)
		return
	}
	errs := coll.Actions().Put(map[string]interface{}{"_id": "Alice", "score": 25}).Do(ctx)
	fmt.Println(errs)
}
Output:

Index

Examples

Constants

View Source
const Scheme = "dynamodb"

Scheme is the URL scheme dynamodb registers its URLOpener under on docstore.DefaultMux.

Variables

This section is empty.

Functions

func Dial added in v0.13.0

Dial gets an AWS DynamoDB service client.

func OpenCollection

func OpenCollection(db *dyn.DynamoDB, tableName, partitionKey, sortKey string) (*docstore.Collection, error)

OpenCollection creates a *docstore.Collection representing a DynamoDB collection.

Types

type URLOpener added in v0.13.0

type URLOpener struct {
	// ConfigProvider must be set to a non-nil value.
	ConfigProvider client.ConfigProvider
}

URLOpener opens dynamodb URLs like "dynamodb://mytable?partition_key=partkey&sort_key=sortkey".

The URL Host is used as the table name. See https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html for more details.

The following query parameters are supported:

  • partition_key (required): the path to the partition key of a table or an index.
  • sort_key: the path to the sort key of a table or an index.

See https://godoc.org/gocloud.dev/aws#ConfigFromURLParams for supported query parameters for overriding the aws.Session from the URL.

func (*URLOpener) OpenCollectionURL added in v0.13.0

func (o *URLOpener) OpenCollectionURL(_ context.Context, u *url.URL) (*docstore.Collection, error)

OpenCollectionURL opens the collection at the URL's path. See the package doc for more details.

Jump to

Keyboard shortcuts

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