Documentation ¶
Index ¶
- Variables
- func LoadStruct(ctx context.Context, dst interface{}, p []Property) error
- type Batch
- type Client
- type ClientGenerator
- type ClientOption
- type Commit
- type Cursor
- type Entity
- type ErrFieldMismatch
- type GeoPoint
- type Iterator
- type Key
- type KeyLoader
- type MultiError
- type PendingKey
- type Property
- type PropertyList
- type PropertyLoadSaver
- type PropertyTranslator
- type PutResult
- type Query
- type Transaction
- type TransactionBatch
- func (b *TransactionBatch) Delete(key Key) chan error
- func (b *TransactionBatch) Exec() error
- func (b *TransactionBatch) Get(key Key, dst interface{}) chan error
- func (b *TransactionBatch) Put(key Key, src interface{}) chan *TransactionPutResult
- func (b *TransactionBatch) UnwrapPutResult(r *TransactionPutResult) (PendingKey, error)
- type TransactionPutResult
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidEntityType = errors.New("datastore: invalid entity type") ErrInvalidKey = errors.New("datastore: invalid key") ErrNoSuchEntity = errors.New("datastore: no such entity") )
var ErrConcurrentTransaction = errors.New("datastore: concurrent transaction")
var LoadEntity = loadEntity
TODO hide LoadEntity project outside
var SaveEntity = saveEntity
var SuppressErrFieldMismatch = true
Functions ¶
func LoadStruct ¶
LoadStruct loads the properties from p to dst. dst must be a struct pointer.
The values of dst's unmatched struct fields are not modified, and matching slice-typed fields are not reset before appending to them. In particular, it is recommended to pass a pointer to a zero valued struct on each LoadStruct call.
Types ¶
type Client ¶
type Client interface { Get(ctx context.Context, key Key, dst interface{}) error GetMulti(ctx context.Context, keys []Key, dst interface{}) error Put(ctx context.Context, key Key, src interface{}) (Key, error) PutMulti(ctx context.Context, keys []Key, src interface{}) ([]Key, error) Delete(ctx context.Context, key Key) error DeleteMulti(ctx context.Context, keys []Key) error NewTransaction(ctx context.Context) (Transaction, error) RunInTransaction(ctx context.Context, f func(tx Transaction) error) (Commit, error) Run(ctx context.Context, q Query) Iterator AllocatedIDs(ctx context.Context, keys []Key) ([]Key, error) Count(ctx context.Context, q Query) (int, error) GetAll(ctx context.Context, q Query, dst interface{}) ([]Key, error) IncompleteKey(kind string, parent Key) Key NameKey(kind, name string, parent Key) Key IDKey(kind string, id int64, parent Key) Key NewQuery(kind string) Query Close() error DecodeCursor(s string) (Cursor, error) Batch() *Batch }
type ClientGenerator ¶
type ClientGenerator func(ctx context.Context, opts ...ClientOption) (Client, error)
var FromContext ClientGenerator
type ClientOption ¶
type ClientOption interface {
Apply(*internal.ClientSettings)
}
func WithCredentialsFile ¶
func WithCredentialsFile(filename string) ClientOption
WithCredentialsFile returns a ClientOption that authenticates API calls with the given service account or refresh token JSON credentials file.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) ClientOption
WithHTTPClient returns a ClientOption that specifies the HTTP client to use as the basis of communications. This option may only be used with services that support HTTP as their communication transport. When used, the WithHTTPClient option takes precedent over all other supplied options.
func WithProjectID ¶
func WithProjectID(projectID string) ClientOption
func WithScopes ¶
func WithScopes(scope ...string) ClientOption
WithScopes returns a ClientOption that overrides the default OAuth2 scopes to be used for a service.
func WithTokenSource ¶
func WithTokenSource(s oauth2.TokenSource) ClientOption
WithTokenSource returns a ClientOption that specifies an OAuth2 token source to be used as the basis for authentication.
type Commit ¶
type Commit interface {
Key(p PendingKey) Key
}
type ErrFieldMismatch ¶
ErrFieldMismatch is returned when a field is to be loaded into a different type than the one it was stored from, or when a field is missing or unexported in the destination struct. StructType is the type of the struct pointed to by the destination argument passed to Get or to Iterator.Next.
func (*ErrFieldMismatch) Error ¶
func (e *ErrFieldMismatch) Error() string
type KeyLoader ¶
type KeyLoader interface { PropertyLoadSaver LoadKey(ctx context.Context, k Key) error }
type MultiError ¶
type MultiError []error
MultiError is returned by batch operations when there are errors with particular elements. Errors will be in a one-to-one correspondence with the input elements; successful elements will have a nil entry.
func (MultiError) Error ¶
func (m MultiError) Error() string
type PendingKey ¶
type PropertyList ¶
type PropertyList []Property
type PropertyLoadSaver ¶
type PropertyTranslator ¶
type Query ¶
type Query interface { Ancestor(ancestor Key) Query EventualConsistency() Query Namespace(ns string) Query Transaction(t Transaction) Query Filter(filterStr string, value interface{}) Query Order(fieldName string) Query Project(fieldNames ...string) Query Distinct() Query // NOT IMPLEMENTED ON APPENGINE DistinctOn(fieldNames ...string) *Query KeysOnly() Query Limit(limit int) Query Offset(offset int) Query Start(c Cursor) Query End(c Cursor) Query }
type Transaction ¶
type Transaction interface { Get(key Key, dst interface{}) error GetMulti(keys []Key, dst interface{}) error Put(key Key, src interface{}) (PendingKey, error) PutMulti(keys []Key, src interface{}) ([]PendingKey, error) Delete(key Key) error DeleteMulti(keys []Key) error Commit() (Commit, error) Rollback() error Batch() *TransactionBatch }
type TransactionBatch ¶
type TransactionBatch struct { Transaction Transaction // contains filtered or unexported fields }
func (*TransactionBatch) Delete ¶
func (b *TransactionBatch) Delete(key Key) chan error
func (*TransactionBatch) Exec ¶
func (b *TransactionBatch) Exec() error
func (*TransactionBatch) Get ¶
func (b *TransactionBatch) Get(key Key, dst interface{}) chan error
func (*TransactionBatch) Put ¶
func (b *TransactionBatch) Put(key Key, src interface{}) chan *TransactionPutResult
func (*TransactionBatch) UnwrapPutResult ¶
func (b *TransactionBatch) UnwrapPutResult(r *TransactionPutResult) (PendingKey, error)
type TransactionPutResult ¶
type TransactionPutResult struct { PendingKey PendingKey Err error }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
c/atomiccache
Package atomiccache provides a map-based cache that supports very fast reads.
|
Package atomiccache provides a map-based cache that supports very fast reads. |
c/fields
Package fields provides a view of the fields of a struct that follows the Go rules, amended to consider tags and case insensitivity.
|
Package fields provides a view of the fields of a struct that follows the Go rules, amended to consider tags and case insensitivity. |