Documentation ¶
Overview ¶
Package session provides github.com/speedland/go/web/middleware/session.SessionStore implementation for GAE environment
Index ¶
- Constants
- Variables
- type GAESessionStore
- type Session
- type SessionKind
- func (k *SessionKind) Delete(ctx context.Context, key interface{}) (*datastore.Key, error)
- func (k *SessionKind) DeleteMatched(ctx context.Context, q *SessionQuery) (int, error)
- func (k *SessionKind) DeleteMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, error)
- func (k *SessionKind) EnforceNamespace(ns string, b bool) *SessionKind
- func (k *SessionKind) Get(ctx context.Context, key interface{}) (*datastore.Key, *Session, error)
- func (k *SessionKind) GetMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, []*Session, error)
- func (k *SessionKind) MustDelete(ctx context.Context, key interface{}) *datastore.Key
- func (k *SessionKind) MustDeleteMulti(ctx context.Context, keys interface{}) []*datastore.Key
- func (k *SessionKind) MustGet(ctx context.Context, key interface{}) *Session
- func (k *SessionKind) MustGetMulti(ctx context.Context, keys interface{}) []*Session
- func (k *SessionKind) MustPut(ctx context.Context, ent *Session) *datastore.Key
- func (k *SessionKind) MustPutMulti(ctx context.Context, ents []*Session) []*datastore.Key
- func (k *SessionKind) MustReplace(ctx context.Context, ent *Session, replacer SessionKindReplacer) (*datastore.Key, *Session)
- func (k *SessionKind) MustReplaceMulti(ctx context.Context, ents []*Session, replacer SessionKindReplacer) ([]*datastore.Key, []*Session)
- func (k *SessionKind) Put(ctx context.Context, ent *Session) (*datastore.Key, error)
- func (k *SessionKind) PutMulti(ctx context.Context, ents []*Session) ([]*datastore.Key, error)
- func (k *SessionKind) Replace(ctx context.Context, ent *Session, replacer SessionKindReplacer) (*datastore.Key, *Session, error)
- func (k *SessionKind) ReplaceMulti(ctx context.Context, ents []*Session, replacer SessionKindReplacer) ([]*datastore.Key, []*Session, error)
- func (k *SessionKind) UseDefaultIfNil(b bool) *SessionKind
- type SessionKindReplacer
- type SessionKindReplacerFunc
- type SessionPagination
- type SessionQuery
- func (q *SessionQuery) Ancestor(a lazy.Value) *SessionQuery
- func (q *SessionQuery) Asc(name string) *SessionQuery
- func (q *SessionQuery) Count(ctx context.Context) (int, error)
- func (q *SessionQuery) Desc(name string) *SessionQuery
- func (q *SessionQuery) End(value lazy.Value) *SessionQuery
- func (q *SessionQuery) Eq(name string, value lazy.Value) *SessionQuery
- func (q *SessionQuery) Ge(name string, value lazy.Value) *SessionQuery
- func (q *SessionQuery) GetAll(ctx context.Context) ([]*datastore.Key, []*Session, error)
- func (q *SessionQuery) GetAllValues(ctx context.Context) ([]*Session, error)
- func (q *SessionQuery) Gt(name string, value lazy.Value) *SessionQuery
- func (q *SessionQuery) Le(name string, value lazy.Value) *SessionQuery
- func (q *SessionQuery) Limit(n lazy.Value) *SessionQuery
- func (q *SessionQuery) Lt(name string, value lazy.Value) *SessionQuery
- func (q *SessionQuery) MustCount(ctx context.Context) int
- func (q *SessionQuery) MustGetAll(ctx context.Context) ([]*datastore.Key, []*Session)
- func (q *SessionQuery) MustGetAllValues(ctx context.Context) []*Session
- func (q *SessionQuery) MustRun(ctx context.Context) *SessionPagination
- func (q *SessionQuery) Ne(name string, value lazy.Value) *SessionQuery
- func (q *SessionQuery) Run(ctx context.Context) (*SessionPagination, error)
- func (q *SessionQuery) Start(value lazy.Value) *SessionQuery
- func (q *SessionQuery) ViaKeys(k *SessionKind) *SessionQuery
Constants ¶
const LoggerKey = session.SessionLoggerKey
const SessionKindLoggerKey = "ent.session"
SessionKindLoggerKey is a logger key name for the ent
const SessionQueryLoggerKey = "ent.query.session"
SessionQueryLoggerKey is a logger key name for the ent
Variables ¶
var DefaultSessionKind = &SessionKind{}
DefaultSessionKind is a default value of *SessionKind
Functions ¶
This section is empty.
Types ¶
type GAESessionStore ¶
type GAESessionStore struct {
// contains filtered or unexported fields
}
GAESessionStore implements SessionStore on GAE memcache and datastore
func NewGAESessionStore ¶
func NewGAESessionStore(namespace string) *GAESessionStore
NewGAESessionStore returns a new *SessionStore
func (*GAESessionStore) String ¶
func (s *GAESessionStore) String() string
type Session ¶
type Session struct { ID string `json:"id" ent:"id"` CSRFSecret string `json:"csrf_secret" datastore:",noindex"` Timestamp time.Time `json:"key" ent:"timestamp" datastore:",noindex"` Data []byte `json:"data" datastore:",noindex"` }
Session is a wrapped struct for github.com/speedland/go/web/middleware/sesison.Session
func NewSession ¶
func NewSession() *Session
NewSession returns a new *Session with default field values.
func (*Session) UpdateByForm ¶
UpdateByForm updates the fields by form values. All values should be validated before calling this function.
type SessionKind ¶
type SessionKind struct {
// contains filtered or unexported fields
}
func (*SessionKind) DeleteMatched ¶
func (k *SessionKind) DeleteMatched(ctx context.Context, q *SessionQuery) (int, error)
DeleteMatched deletes the all ents that match with the query. This func modify Limit/StartKey condition in the query so that you should restore it if you want to reuse the query.
func (*SessionKind) DeleteMulti ¶
DeleteMulti do Delete with multiple keys
func (*SessionKind) EnforceNamespace ¶
func (k *SessionKind) EnforceNamespace(ns string, b bool) *SessionKind
EnforceNamespace enforces namespace for Get/Put/Delete or not.
func (*SessionKind) GetMulti ¶
func (k *SessionKind) GetMulti(ctx context.Context, keys interface{}) ([]*datastore.Key, []*Session, error)
GetMulti do Get with multiple keys. keys must be []string, []*datastore.Key, or []interface{}
func (*SessionKind) MustDelete ¶
func (k *SessionKind) MustDelete(ctx context.Context, key interface{}) *datastore.Key
MustDelete is like Delete but panic if an error occurs
func (*SessionKind) MustDeleteMulti ¶
func (k *SessionKind) MustDeleteMulti(ctx context.Context, keys interface{}) []*datastore.Key
MustDeleteMulti is like DeleteMulti but panic if an error occurs
func (*SessionKind) MustGet ¶
func (k *SessionKind) MustGet(ctx context.Context, key interface{}) *Session
MustGet is like Get but returns only values and panic if error happens.
func (*SessionKind) MustGetMulti ¶
func (k *SessionKind) MustGetMulti(ctx context.Context, keys interface{}) []*Session
MustGetMulti is like GetMulti but returns only values and panic if error happens.
func (*SessionKind) MustPutMulti ¶
MustPutMulti is like PutMulti but panic if an error occurs
func (*SessionKind) MustReplace ¶
func (k *SessionKind) MustReplace(ctx context.Context, ent *Session, replacer SessionKindReplacer) (*datastore.Key, *Session)
func (*SessionKind) MustReplaceMulti ¶
func (k *SessionKind) MustReplaceMulti(ctx context.Context, ents []*Session, replacer SessionKindReplacer) ([]*datastore.Key, []*Session)
func (*SessionKind) Replace ¶
func (k *SessionKind) Replace(ctx context.Context, ent *Session, replacer SessionKindReplacer) (*datastore.Key, *Session, error)
func (*SessionKind) ReplaceMulti ¶
func (k *SessionKind) ReplaceMulti(ctx context.Context, ents []*Session, replacer SessionKindReplacer) ([]*datastore.Key, []*Session, error)
func (*SessionKind) UseDefaultIfNil ¶
func (k *SessionKind) UseDefaultIfNil(b bool) *SessionKind
type SessionKindReplacer ¶
type SessionKindReplacerFunc ¶
type SessionPagination ¶
type SessionQuery ¶
type SessionQuery struct {
// contains filtered or unexported fields
}
SessionQuery helps to build and execute a query
func NewSessionQuery ¶
func NewSessionQuery() *SessionQuery
func (*SessionQuery) Ancestor ¶
func (q *SessionQuery) Ancestor(a lazy.Value) *SessionQuery
Ancestor sets the ancestor filter
func (*SessionQuery) Asc ¶
func (q *SessionQuery) Asc(name string) *SessionQuery
Asc specifies ascending order on the given filed.
func (*SessionQuery) Count ¶
func (q *SessionQuery) Count(ctx context.Context) (int, error)
Count returns the count of entities
func (*SessionQuery) Desc ¶
func (q *SessionQuery) Desc(name string) *SessionQuery
Desc specifies descending order on the given filed.
func (*SessionQuery) End ¶
func (q *SessionQuery) End(value lazy.Value) *SessionQuery
Limit specifies the numbe of limit returend by this query.
func (*SessionQuery) Eq ¶
func (q *SessionQuery) Eq(name string, value lazy.Value) *SessionQuery
Eq sets the "=" filter on the name field.
func (*SessionQuery) Ge ¶
func (q *SessionQuery) Ge(name string, value lazy.Value) *SessionQuery
Ge sets the ">=" filter on the "name" field.
func (*SessionQuery) GetAllValues ¶
func (q *SessionQuery) GetAllValues(ctx context.Context) ([]*Session, error)
GetAllValues is like GetAll but returns only values
func (*SessionQuery) Gt ¶
func (q *SessionQuery) Gt(name string, value lazy.Value) *SessionQuery
Gt sets the ">" filter on the "name" field.
func (*SessionQuery) Le ¶
func (q *SessionQuery) Le(name string, value lazy.Value) *SessionQuery
Le sets the "<=" filter on the "name" field.
func (*SessionQuery) Limit ¶
func (q *SessionQuery) Limit(n lazy.Value) *SessionQuery
Limit specifies the numbe of limit returend by this query.
func (*SessionQuery) Lt ¶
func (q *SessionQuery) Lt(name string, value lazy.Value) *SessionQuery
Lt sets the "<" filter on the "name" field.
func (*SessionQuery) MustCount ¶
func (q *SessionQuery) MustCount(ctx context.Context) int
MustCount returns the count of entities
func (*SessionQuery) MustGetAll ¶
MustGetAll is like GetAll but panic if an error occurrs.
func (*SessionQuery) MustGetAllValues ¶
func (q *SessionQuery) MustGetAllValues(ctx context.Context) []*Session
MustGetAllValues is like GetAllValues but panic if an error occurrs
func (*SessionQuery) MustRun ¶
func (q *SessionQuery) MustRun(ctx context.Context) *SessionPagination
MustRun is like Run but panic if an error occurrs
func (*SessionQuery) Ne ¶
func (q *SessionQuery) Ne(name string, value lazy.Value) *SessionQuery
Ne sets the "!=" filter on the "name" field.
func (*SessionQuery) Run ¶
func (q *SessionQuery) Run(ctx context.Context) (*SessionPagination, error)
Run returns the a result as *SessionPagination object
func (*SessionQuery) Start ¶
func (q *SessionQuery) Start(value lazy.Value) *SessionQuery
Limit specifies the numbe of limit returend by this query.
func (*SessionQuery) ViaKeys ¶
func (q *SessionQuery) ViaKeys(k *SessionKind) *SessionQuery
ViaKeys optimize to execute keys-only query then call k.GetMulti() to fetch values. This would reduce the datastore query and maximize the memcache usage if the query called many times in a short time window.