Documentation ¶
Index ¶
- Constants
- func AcquireSequence(c GAEContext, name string, size int) (first int64, err error)
- func AcquireSequenceNo(c GAEContext, name string) (result int64, err error)
- func CallTransactionFunction(c GAEContext, f interface{}) (err error)
- func DataHandlerFunc(f func(c HTTPContext) (resp *httpcontext.DataResp, err error), ...) http.Handler
- func DocHandle(router *mux.Router, f interface{}, path string, method string, ...)
- func HTTPHandlerFunc(f func(c HTTPContext) error, scopes ...string) http.Handler
- func JSONHandlerFunc(f func(c JSONContext) (resp jsoncontext.Resp, err error), ...) http.Handler
- func KindsRenderer(c JSONContext) (status int, result []string, err error)
- func ServiceStatusRenderer(ok4xxRatio, ok5xxRatio float64) func(c JSONContext) (status int, result *ServiceStatus, err error)
- type Counter
- type DefaultContext
- func (self *DefaultContext) AfterCreate(i interface{}) error
- func (self *DefaultContext) AfterDelete(i interface{}) error
- func (self *DefaultContext) AfterLoad(i interface{}) error
- func (self *DefaultContext) AfterSave(i interface{}) error
- func (self *DefaultContext) AfterTransaction(f interface{}) (err error)
- func (self *DefaultContext) AfterUpdate(i interface{}) error
- func (self *DefaultContext) BeforeCreate(i interface{}) error
- func (self *DefaultContext) BeforeDelete(i interface{}) error
- func (self *DefaultContext) BeforeSave(i interface{}) error
- func (self *DefaultContext) BeforeUpdate(i interface{}) error
- func (self *DefaultContext) Client() *http.Client
- func (self *DefaultContext) ClientTimeout(d time.Duration)
- func (self *DefaultContext) Criticalf(format string, i ...interface{})
- func (self *DefaultContext) Debugf(format string, i ...interface{})
- func (self *DefaultContext) Errorf(format string, i ...interface{})
- func (self *DefaultContext) GetAllowHTTPDuringTransactions() bool
- func (self *DefaultContext) InTransaction() bool
- func (self *DefaultContext) Infof(format string, i ...interface{})
- func (self *DefaultContext) SetAllowHTTPDuringTransactions(b bool)
- func (self *DefaultContext) Transaction(f interface{}, crossGroup bool) (err error)
- func (self *DefaultContext) Warningf(format string, i ...interface{})
- type DefaultHTTPContext
- type DefaultJSONContext
- type ErrLockTaken
- type GAEContext
- type HTTPContext
- type JSONContext
- type KeyLock
- type ServiceStatus
- type Transport
Constants ¶
const (
GAEContextCounterKind = "GAEContextCounterKind"
)
Variables ¶
This section is empty.
Functions ¶
func AcquireSequence ¶
func AcquireSequence(c GAEContext, name string, size int) (first int64, err error)
func AcquireSequenceNo ¶
func AcquireSequenceNo(c GAEContext, name string) (result int64, err error)
AcquireSequenceNo will return the next number in the named sequence.
func CallTransactionFunction ¶
func CallTransactionFunction(c GAEContext, f interface{}) (err error)
CallTransactionFunction will validate that f takes something that implements a GAEContext, and that it returns an error. Then it will call f with c and return the error.
func DataHandlerFunc ¶
func DataHandlerFunc(f func(c HTTPContext) (resp *httpcontext.DataResp, err error), scopes ...string) http.Handler
DataHandlerFunc creates an http.Handler out of a function that takes an HTTPContext and returns a *httpcontext.DataResp.
Requests without tokens, or with tokens without one of the provided scopes, will receive a 401 status unless the scopes slice is empty.
For all your tabular data generation needs.
func DocHandle ¶
func DocHandle(router *mux.Router, f interface{}, path string, method string, minAPIVersion, maxAPIVersion int, scopes ...string)
DocHandle registeres a path/method/api version route in the provided router, handled by the provided f, wrapping it in appstats.NewHandler, registering the f-function and its route with jsoncontext.Document and then using jsoncontext.Handle to do something that acts like JSONHandlerFunc.
func HTTPHandlerFunc ¶
func HTTPHandlerFunc(f func(c HTTPContext) error, scopes ...string) http.Handler
HTTPHandlerFunc creates an http.Handler out of a function that takes a HTTPContext.
Requests without tokens, or with tokens without one of the provided scopes, will receive a 401 status unless the scopes slice is empty.
For all your basic HTTP needs.
func JSONHandlerFunc ¶
func JSONHandlerFunc(f func(c JSONContext) (resp jsoncontext.Resp, err error), minAPIVersion, maxAPIVersion int, scopes ...string) http.Handler
JSONHandlerFunc creates an http.Handler out of a function that takes a JSONContext.
Requests without tokens, or with tokens without one of the provided scopes, will receive a 401 status unless the scopes slice is empty.
For all your JSON API needs.
func KindsRenderer ¶
func KindsRenderer(c JSONContext) (status int, result []string, err error)
func ServiceStatusRenderer ¶
func ServiceStatusRenderer(ok4xxRatio, ok5xxRatio float64) func(c JSONContext) (status int, result *ServiceStatus, err error)
Types ¶
type DefaultContext ¶
func NewContext ¶
func NewContext(gaeCont context.Context) (result *DefaultContext)
func (*DefaultContext) AfterCreate ¶
func (self *DefaultContext) AfterCreate(i interface{}) error
func (*DefaultContext) AfterDelete ¶
func (self *DefaultContext) AfterDelete(i interface{}) error
func (*DefaultContext) AfterLoad ¶
func (self *DefaultContext) AfterLoad(i interface{}) error
func (*DefaultContext) AfterSave ¶
func (self *DefaultContext) AfterSave(i interface{}) error
Implement all the hook functions required by Context
func (*DefaultContext) AfterTransaction ¶
func (self *DefaultContext) AfterTransaction(f interface{}) (err error)
AfterTransaction will call f directly if self is not currently running a transaction, otherwise it will be appended to a slice of funcs run after every transaction is finished.
func (*DefaultContext) AfterUpdate ¶
func (self *DefaultContext) AfterUpdate(i interface{}) error
func (*DefaultContext) BeforeCreate ¶
func (self *DefaultContext) BeforeCreate(i interface{}) error
func (*DefaultContext) BeforeDelete ¶
func (self *DefaultContext) BeforeDelete(i interface{}) error
func (*DefaultContext) BeforeSave ¶
func (self *DefaultContext) BeforeSave(i interface{}) error
func (*DefaultContext) BeforeUpdate ¶
func (self *DefaultContext) BeforeUpdate(i interface{}) error
func (*DefaultContext) Client ¶
func (self *DefaultContext) Client() *http.Client
Client will return an *http.Client with a nice Transport wrapper.
func (*DefaultContext) ClientTimeout ¶
func (self *DefaultContext) ClientTimeout(d time.Duration)
func (*DefaultContext) Criticalf ¶
func (self *DefaultContext) Criticalf(format string, i ...interface{})
func (*DefaultContext) Debugf ¶
func (self *DefaultContext) Debugf(format string, i ...interface{})
func (*DefaultContext) Errorf ¶
func (self *DefaultContext) Errorf(format string, i ...interface{})
func (*DefaultContext) GetAllowHTTPDuringTransactions ¶
func (self *DefaultContext) GetAllowHTTPDuringTransactions() bool
func (*DefaultContext) InTransaction ¶
func (self *DefaultContext) InTransaction() bool
func (*DefaultContext) Infof ¶
func (self *DefaultContext) Infof(format string, i ...interface{})
func (*DefaultContext) SetAllowHTTPDuringTransactions ¶
func (self *DefaultContext) SetAllowHTTPDuringTransactions(b bool)
func (*DefaultContext) Transaction ¶
func (self *DefaultContext) Transaction(f interface{}, crossGroup bool) (err error)
Transaction will run f inside a transaction, optionally crossGroup (more than 1 but LESS THAN FIVE entity groups involved).
If it fails due to other concurrent transactions, it will retry this transaction up until 20 seconds have passed.
func (*DefaultContext) Warningf ¶
func (self *DefaultContext) Warningf(format string, i ...interface{})
type DefaultHTTPContext ¶
type DefaultHTTPContext struct { GAEContext httpcontext.HTTPContext }
func NewHTTPContext ¶
func NewHTTPContext(gaeCont context.Context, httpCont httpcontext.HTTPContext) (result *DefaultHTTPContext)
func (*DefaultHTTPContext) Transaction ¶
func (self *DefaultHTTPContext) Transaction(f interface{}, crossGroup bool) error
type DefaultJSONContext ¶
type DefaultJSONContext struct { GAEContext jsoncontext.JSONContext }
func NewJSONContext ¶
func NewJSONContext(gaeCont context.Context, jsonCont jsoncontext.JSONContext) (result *DefaultJSONContext)
func (*DefaultJSONContext) Transaction ¶
func (self *DefaultJSONContext) Transaction(f interface{}, crossGroup bool) error
type ErrLockTaken ¶
func (ErrLockTaken) Error ¶
func (self ErrLockTaken) Error() string
func (ErrLockTaken) GetStack ¶
func (self ErrLockTaken) GetStack() string
type GAEContext ¶
type HTTPContext ¶
type HTTPContext interface { GAEContext httpcontext.HTTPContext }
type JSONContext ¶
type JSONContext interface { GAEContext jsoncontext.JSONContext }
type KeyLock ¶
type KeyLock struct { // Id must be created based on the value you want to lock. Id key.Key `datastore:"-"` // Entity is the id of the holder of the lock. Entity key.Key }
KeyLock is a generic way of locking certain values for entities without needing the entities have that value in their key.
func (*KeyLock) Lock ¶
func (self *KeyLock) Lock(c GAEContext) error
Lock will try to lock this KeyLock and make its Id (and the value it is based on) unavailable for other locks.
func (*KeyLock) LockedBy ¶
LockedBy will return whether this KeyLock is actually locked in the database and who holds it now.
func (*KeyLock) Unlock ¶
func (self *KeyLock) Unlock(c GAEContext) (err error)
Unlock will unlock this KeyLock and make its Id (and the value it is based on) available for other locks.