Documentation ¶
Index ¶
- Variables
- func SetProvider(ctx context.Context, p DatastoreProvider) context.Context
- type CloudDSProvider
- func (p CloudDSProvider) Criticalf(ctx context.Context, format string, args ...interface{})
- func (p CloudDSProvider) Debugf(ctx context.Context, format string, args ...interface{})
- func (p CloudDSProvider) DecodeKey(encoded string) (Keyer, error)
- func (p CloudDSProvider) Delete(ctx context.Context, keyer Keyer) error
- func (p CloudDSProvider) DeleteMulti(ctx context.Context, keyers []Keyer) error
- func (p CloudDSProvider) Errorf(ctx context.Context, format string, args ...interface{})
- func (p CloudDSProvider) Get(ctx context.Context, keyer Keyer, dst interface{}) error
- func (p CloudDSProvider) GetAll(ctx context.Context, q *Query, dst interface{}) ([]Keyer, error)
- func (p CloudDSProvider) GetMulti(ctx context.Context, keyers []Keyer, dst interface{}) error
- func (p CloudDSProvider) HTTPClient(ctx context.Context) *http.Client
- func (p CloudDSProvider) Infof(ctx context.Context, format string, args ...interface{})
- func (p CloudDSProvider) KeyName(in Keyer) string
- func (p CloudDSProvider) KeyParent(in Keyer) Keyer
- func (p CloudDSProvider) NewIDKey(ctx context.Context, kind string, id int64, root Keyer) Keyer
- func (p CloudDSProvider) NewIncompleteKey(ctx context.Context, kind string, root Keyer) Keyer
- func (p CloudDSProvider) NewNameKey(ctx context.Context, kind, name string, root Keyer) Keyer
- func (p CloudDSProvider) Put(ctx context.Context, keyer Keyer, src interface{}) (Keyer, error)
- func (p CloudDSProvider) PutMulti(ctx context.Context, keyers []Keyer, src interface{}) ([]Keyer, error)
- func (p CloudDSProvider) Warningf(ctx context.Context, format string, args ...interface{})
- type DatastoreProvider
- type Filter
- type Iterator
- type Keyer
- type Query
- func (q *Query) Ancestor(keyer Keyer) *Query
- func (q *Query) Distinct() *Query
- func (q *Query) Filter(field string, val interface{}) *Query
- func (q *Query) KeysOnly() *Query
- func (q *Query) Limit(l int) *Query
- func (q *Query) Order(o string) *Query
- func (q *Query) Project(fields ...string) *Query
- func (q *Query) String() string
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoSuchEntity = errors.New("dsprovider: no such entity") ErrFieldMismatch = errors.New("dsprovider: src obj had a field that dst obj didn't") ErrNoMemcacheService = errors.New("dsprovider: no memcache service available") )
var Debug = false
Functions ¶
func SetProvider ¶
func SetProvider(ctx context.Context, p DatastoreProvider) context.Context
SetProvider embeds a provider inside a Context, for later retrieval
Types ¶
type CloudDSProvider ¶
type CloudDSProvider struct { Project string // contains filtered or unexported fields }
CloudDSProvider implements the DatastoreProvider interface using the cloud datastore API, for use outside of appengine environments.
func NewCloudDSProvider ¶
func NewCloudDSProvider(ctx context.Context, project string) (*CloudDSProvider, error)
func (CloudDSProvider) Criticalf ¶
func (p CloudDSProvider) Criticalf(ctx context.Context, format string, args ...interface{})
func (CloudDSProvider) Debugf ¶
func (p CloudDSProvider) Debugf(ctx context.Context, format string, args ...interface{})
func (CloudDSProvider) DecodeKey ¶
func (p CloudDSProvider) DecodeKey(encoded string) (Keyer, error)
func (CloudDSProvider) Delete ¶
func (p CloudDSProvider) Delete(ctx context.Context, keyer Keyer) error
func (CloudDSProvider) DeleteMulti ¶
func (p CloudDSProvider) DeleteMulti(ctx context.Context, keyers []Keyer) error
func (CloudDSProvider) Errorf ¶
func (p CloudDSProvider) Errorf(ctx context.Context, format string, args ...interface{})
func (CloudDSProvider) Get ¶
func (p CloudDSProvider) Get(ctx context.Context, keyer Keyer, dst interface{}) error
func (CloudDSProvider) GetMulti ¶
func (p CloudDSProvider) GetMulti(ctx context.Context, keyers []Keyer, dst interface{}) error
func (CloudDSProvider) HTTPClient ¶
func (p CloudDSProvider) HTTPClient(ctx context.Context) *http.Client
func (CloudDSProvider) Infof ¶
func (p CloudDSProvider) Infof(ctx context.Context, format string, args ...interface{})
func (CloudDSProvider) KeyName ¶
func (p CloudDSProvider) KeyName(in Keyer) string
func (CloudDSProvider) KeyParent ¶
func (p CloudDSProvider) KeyParent(in Keyer) Keyer
func (CloudDSProvider) NewIncompleteKey ¶
func (CloudDSProvider) NewNameKey ¶
type DatastoreProvider ¶
type DatastoreProvider interface { Get(ctx context.Context, keyer Keyer, dst interface{}) error GetMulti(ctx context.Context, keyers []Keyer, dst interface{}) error GetAll(ctx context.Context, q *Query, dst interface{}) ([]Keyer, error) Put(ctx context.Context, keyer Keyer, src interface{}) (Keyer, error) PutMulti(ctx context.Context, keyers []Keyer, src interface{}) ([]Keyer, error) Delete(ctx context.Context, keyer Keyer) error DeleteMulti(ctx context.Context, keyers []Keyer) error NewIncompleteKey(ctx context.Context, kind string, root Keyer) Keyer NewNameKey(ctx context.Context, kind, name string, root Keyer) Keyer NewIDKey(ctx context.Context, kind string, id int64, root Keyer) Keyer DecodeKey(encoded string) (Keyer, error) KeyParent(Keyer) Keyer KeyName(Keyer) string // HTTP client - maybe urlfetch, maybe not HTTPClient(ctx context.Context) *http.Client // Logging support - goes to appengine logging, or maybe STDOUT Debugf(ctx context.Context, format string, args ...interface{}) Infof(ctx context.Context, format string, args ...interface{}) Warningf(ctx context.Context, format string, args ...interface{}) Errorf(ctx context.Context, format string, args ...interface{}) Criticalf(ctx context.Context, format string, args ...interface{}) }
Provider is a wrapper over the datastore APIs (cloud and appengine), so that client code (and in particular query assembley) can run both inside and outside of google appengine.
In fact, it wraps all the appengine APIs (incl. /log and /urlfetch), so we don't need to worry about any appengine libs except in util/ae/ds.
func GetProviderOrPanic ¶
func GetProviderOrPanic(ctx context.Context) DatastoreProvider
GetProvider retrieves the provider from the context; panics if not found
type Iterator ¶
type Iterator struct { PageSize int Slice interface{} // The current page of results // contains filtered or unexported fields }
Iterator is a batching iterator that executes the full query up front, to get a list of all keys; then it fetches pages of results as it works through the keys. We don't use datastore.Iterator, as it times out the result set after 60 seconds, out of abundance of caution.
func NewIterator ¶
func NewIterator(ctx context.Context, p DatastoreProvider, q *Query, obj interface{}) *Iterator
Snarf down all the keys from the get go.
func (*Iterator) ValAsInterface ¶
func (iter *Iterator) ValAsInterface() interface{}
ValAsInterface returns the val as the base interface; it will need a type assertion back into the relevant type.
type Keyer ¶
type Keyer interface {
Encode() string
}
Keyer is a very thin wrapper. It should be populated with a *datastore.Key