Documentation ¶
Overview ¶
Package driver defines a set of interfaces that the docstore package uses to interact with the underlying services.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UniqueString ¶
func UniqueString() string
UniqueString generates a string that is unique with high probability. Driver implementations can use it to generate keys for Create actions.
Types ¶
type Action ¶
type Action struct { Kind ActionKind // the kind of action Doc Document // the document on which to perform the action FieldPaths [][]string // field paths to retrieve, for Get only Mods []Mod // modifications to make, for Update only }
An Action describes a single operation on a single document.
type ActionKind ¶
type ActionKind int
ActionKind describes the type of an action.
const ( Create ActionKind = iota Replace Put Get Delete Update )
type Collection ¶
type Collection interface { // RunActions executes a sequence of actions. // Implementations are free to execute the actions however they wish, but it must // appear as if they were executed in order. The actions need not happen // atomically. // // RunActions should return immediately after the first action that fails. // The first return value is the number of actions successfully // executed, and the second is the error that caused the action to fail. // // If all actions succeed, RunActions returns (number of actions, nil). RunActions(context.Context, []*Action) (int, error) // ErrorCode should return a code that describes the error, which was returned by // one of the other methods in this interface. ErrorCode(error) gcerr.ErrorCode }
A Collection is a set of documents.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
A Document is a lightweight wrapper around either a map[string]interface{} or a struct pointer. It provides operations to get and set fields and field paths.
func NewDocument ¶
Create a new document from doc, which must be a map[string]interface{} or a struct pointer.
Click to show internal directories.
Click to hide internal directories.