gae

package
v0.0.0-...-f39a356 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: GPL-2.0, GPL-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BeforeCreateName = "BeforeCreate"
	BeforeUpdateName = "BeforeUpdate"
	BeforeSaveName   = "BeforeSave"
	BeforeDeleteName = "BeforeDelete"
	AfterCreateName  = "AfterCreate"
	AfterUpdateName  = "AfterUpdate"
	AfterSaveName    = "AfterSave"
	AfterLoadName    = "AfterLoad"
	AfterDeleteName  = "AfterDelete"
)

Variables

This section is empty.

Functions

func AncestorCounter

func AncestorCounter(model interface{}, fields ...string) func(c PersistenceContext, ancestor key.Key, values ...interface{}) (int, error)

func AncestorFinder

func AncestorFinder(model interface{}, fields ...string) func(c PersistenceContext, dst interface{}, ancestor key.Key, values ...interface{}) error

AncestorFinder will return a finder function that memoizes running a datastore query to find matching models.

It will also register the finder so that MemcacheKeys will return keys to invalidate the result each time a matching model is CRUDed.

The returned function will set the Id field of all found models, and call their AfterLoad functions if any.

func Counter

func Counter(model interface{}, fields ...string) func(c PersistenceContext, values ...interface{}) (int, error)

func Del

func Del(c PersistenceContext, src interface{}) (err error)

Del will delete src from datastore and invalidate it from memcache.

It will also load any old entities with the same id from datastore and run Before/AfterDelete on them

func DelAll

func DelAll(c PersistenceContext, src interface{}) (err error)

func DelQuery

func DelQuery(c PersistenceContext, src interface{}, q *datastore.Query) (err error)

DelQuery will delete (from datastore and memcache) all entities of type src that matches q. src must be a pointer to a struct type.

func FilterOkErrors

func FilterOkErrors(err error, accepted ...error) (result error)

FilterOkErrors will return nil if the provided error is a FieldMismatch, one of the accepted errors, or an appengine.MultiError combination thereof, Otherwise it will return err.

func Finder

func Finder(model interface{}, fields ...string) func(c PersistenceContext, dst interface{}, values ...interface{}) error

Finder will return a finder function that runs a datastore query to find matching models.

The returned function will set the Id field of all found models, and call their AfterLoad functions if any.

func GetAll

func GetAll(c PersistenceContext, src interface{}) (err error)

func GetById

func GetById(c PersistenceContext, dst interface{}) (err error)

GetById will find memoize finding dst in the datastore, setting its id and running its AfterLoad function, if any.

func GetKinds

func GetKinds(c context.Context) (result []string, err error)

func GetMulti

func GetMulti(c PersistenceContext, ids []key.Key, src interface{}) (err error)

func GetQuery

func GetQuery(c PersistenceContext, src interface{}, q *datastore.Query) (err error)

func MemcacheDel

func MemcacheDel(c PersistenceContext, model interface{}) (err error)

func MemcacheKeys

func MemcacheKeys(c PersistenceContext, model interface{}, oldKeys *[]string) (newKeys []string, err error)

MemcacheKeys will append to oldKeys, and also return as newKeys, any memcache keys this package knows about that would result in the provided model being found.

It will use the id based key, and any memcache keys provided by finders created by Finder or AncestorFinder.

func Put

func Put(c PersistenceContext, src interface{}) (err error)

Put will save src in datastore, invalidating cache and running hooks. This requires the loading of any old versions currently in the datastore, which will cause some extra work.

func PutMulti

func PutMulti(c PersistenceContext, src interface{}) (err error)

PutMulti will save src in datastore, invalidating cache and running hooks. This requires the loading of any old versions currently in the datastore, which will cause some extra work.

Types

type ErrNoSuchEntity

type ErrNoSuchEntity struct {
	Type  string
	Cause error
	Id    key.Key
}

ErrNoSuchEntity is just an easily identifiable way of determining that we didn't find what we were looking for, while still providing something the httpcontext types can render as an http response.

func (ErrNoSuchEntity) Error

func (self ErrNoSuchEntity) Error() string

func (ErrNoSuchEntity) GetStatus

func (self ErrNoSuchEntity) GetStatus() int

func (ErrNoSuchEntity) Respond

func (self ErrNoSuchEntity) Respond(c httpcontext.HTTPContext) (err error)

type LogStats

type LogStats struct {
	Records      int
	From         time.Time
	To           time.Time
	Max          int
	Statuses     StatusMap
	TotalLatency time.Duration
	MaxLatency   time.Duration
	MinLatency   time.Duration
	TotalCost    float64
	MaxCost      float64
	MinCost      float64
}

func GetLogStats

func GetLogStats(c context.Context, from, to time.Time, max int, includeDelayTasks bool) (result *LogStats)

type PersistenceContext

type PersistenceContext interface {
	memcache.TransactionContext
	AfterCreate(interface{}) error
	AfterSave(interface{}) error
	AfterUpdate(interface{}) error
	BeforeCreate(interface{}) error
	BeforeSave(interface{}) error
	BeforeUpdate(interface{}) error
	AfterLoad(interface{}) error
	AfterDelete(interface{}) error
	BeforeDelete(interface{}) error
}

type StatusMap

type StatusMap map[int32]int

func (StatusMap) MarshalJSON

func (self StatusMap) MarshalJSON() (b []byte, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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