sessions

package
v0.0.0-...-84d4900 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ErrCantDecData = "can't decode the data"

ErrCantDecData is an error.

View Source
const ErrInvData = "invalid data"
View Source
const ErrItemFound = "item found"
View Source
const ErrIterStop = "iter stop"
View Source
const ErrNotFound = "not found"
View Source
const ErrSessExpired = "session expired"
View Source
const ErrSessFound = "session found"
View Source
const ErrSessInUse = "session is in use"
View Source
const ErrSessNotFound = "session not found"
View Source
const ErrSessionCantStoredat = "can't store data"
View Source
const ErrSessionDataKeyExist = "session data key exist"
View Source
const ErrSessionDataNotFound = "session data not found"
View Source
const ErrUUIDDup = "uuid duplicated"

ErrUUIDDup is the error for duplicated uuid.

Variables

View Source
var DefaultCodec = MsgPackCodec{}

DefaultCodec if the default msgpack codec.

Functions

This section is empty.

Types

type CacheEntry

type CacheEntry struct {
	Sess  Session
	Store map[string]interface{}
	ID    string
	// contains filtered or unexported fields
}

func (*CacheEntry) Del

func (c *CacheEntry) Del(key string) error

func (*CacheEntry) Get

func (c *CacheEntry) Get(key string) (interface{}, error)

func (*CacheEntry) Set

func (c *CacheEntry) Set(key string, data interface{}) error

func (*CacheEntry) UUID

func (c *CacheEntry) UUID() string

type Codec

type Codec interface {
	Encode(interface{}) ([]byte, error)
	Decode([]byte) (interface{}, error)
}

Codec is the interface for encode and decode something.

type KeyFielder

type KeyFielder interface {
	KeyField() interface{}
	Less(x interface{}) bool
	Equal(x interface{}) bool
}

type MemEntry

type MemEntry struct {
	ID    string
	Store map[string]interface{}
	// contains filtered or unexported fields
}

func (*MemEntry) Del

func (m *MemEntry) Del(key string) error

func (*MemEntry) Get

func (m *MemEntry) Get(key string) (interface{}, error)

func (*MemEntry) Set

func (m *MemEntry) Set(key string, data interface{}) error

func (*MemEntry) UUID

func (m *MemEntry) UUID() string

type MemSessions

type MemSessions struct {
	// contains filtered or unexported fields
}

func (*MemSessions) Close

func (m *MemSessions) Close() error

func (*MemSessions) Delete

func (m *MemSessions) Delete(uuid string) error

func (*MemSessions) IsInUse

func (m *MemSessions) IsInUse(uuid string) (bool, error)

func (*MemSessions) New

func (m *MemSessions) New(uuid string) (Session, error)

func (*MemSessions) Restore

func (m *MemSessions) Restore(uuid string) (Session, error)

func (*MemSessions) Return

func (m *MemSessions) Return(s Session) error

func (*MemSessions) Ttl

func (m *MemSessions) Ttl(uuid string) (time.Time, error)

type MsgPackCodec

type MsgPackCodec struct{}

MsgPackCodec implements the encoder and the decoder that is compatible with Codec interface.

func (MsgPackCodec) Decode

func (m MsgPackCodec) Decode(b []byte) (interface{}, error)

Decode something.

func (MsgPackCodec) Encode

func (m MsgPackCodec) Encode(val interface{}) ([]byte, error)

Encode something.

type Ordered

type Ordered []interface{}

func (*Ordered) Del

func (o *Ordered) Del(key interface{}) error

func (*Ordered) Iter

func (o *Ordered) Iter(f func(i int, data interface{}, tx *Transaction) error) error

func (*Ordered) Set

func (o *Ordered) Set(data interface{}) error

type Session

type Session interface {
	UUID() string
	Get(key string) (interface{}, error)
	Set(key string, data interface{}) error
	Del(key string) error
}

func NewCachedEntry

func NewCachedEntry(s Session) Session

func NewMemEntry

func NewMemEntry(uuid string) Session

type SessionBoltDB

type SessionBoltDB struct {
	// contains filtered or unexported fields
}

SessionBoltDB represente a session.

func (*SessionBoltDB) Del

func (s *SessionBoltDB) Del(uuid string) error

Del deletes something under the key.

func (*SessionBoltDB) Get

func (s *SessionBoltDB) Get(key string) (interface{}, error)

Get restore something under the key.

func (*SessionBoltDB) Set

func (s *SessionBoltDB) Set(key string, data interface{}) error

Set store data under the name of key.

func (*SessionBoltDB) UUID

func (s *SessionBoltDB) UUID() string

UUID of this session.

type Sessions

type Sessions interface {
	New(uuid string) (Session, error)
	Restore(uuid string) (Session, error)
	Delete(uuid string) error
	Return(s Session) error
	IsInUse(uuid string) (bool, error)
	Ttl(uuid string) (time.Time, error)
	Close() error
}

func NewMemSessions

func NewMemSessions(ttl, cleanup time.Duration) Sessions

func OpenSessionsBoltDB

func OpenSessionsBoltDB(filename string, perm os.FileMode, opt *bolt.Options, ttl time.Duration, codec Codec) (Sessions, error)

OpenSessionsBoltDB open a session handler.

type SessionsBoltDB

type SessionsBoltDB struct {
	// contains filtered or unexported fields
}

SessionsBoltDB represente a group of sessions.

func (*SessionsBoltDB) Close

func (s *SessionsBoltDB) Close() error

Close the session handler.

func (*SessionsBoltDB) Delete

func (s *SessionsBoltDB) Delete(uuid string) error

Delete session

func (*SessionsBoltDB) IsInUse

func (s *SessionsBoltDB) IsInUse(uuid string) (bool, error)

IsInUse checks is session is in use by someone.

func (*SessionsBoltDB) New

func (s *SessionsBoltDB) New(uuid string) (Session, error)

New creates a new session.

func (*SessionsBoltDB) Restore

func (s *SessionsBoltDB) Restore(uuid string) (Session, error)

Restore a existent session and update the ttl and in use flag.

func (*SessionsBoltDB) Return

func (s *SessionsBoltDB) Return(session Session) error

Return remove session from in use pool.

func (*SessionsBoltDB) Ttl

func (s *SessionsBoltDB) Ttl(uuid string) (time.Time, error)

Ttl returns the time to leave of the session.

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

func NewTransaction

func NewTransaction() *Transaction

func (*Transaction) Commit

func (t *Transaction) Commit(o Ordered) (Ordered, error)

func (*Transaction) Del

func (t *Transaction) Del(key interface{}) error

Jump to

Keyboard shortcuts

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