Documentation ¶
Overview ¶
Package sessionmanager is used to implement model.SM interface. Its purpose is controlling sessions of clients that are used for authentification.
Session manager uses key-value storage Redis for sessions.
Index ¶
- type Config
- type SessionManager
- func (sm *SessionManager) CheckSession(in *model.SessionID) (*model.Session, error)
- func (sm *SessionManager) CreateSession(in *model.Session, expires bool) (*model.SessionID, error)
- func (sm *SessionManager) DeleteSession(in *model.SessionID) error
- func (sm *SessionManager) IsConnected() bool
- func (sm *SessionManager) TryReconnect() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { DBAddress string `json:"DBAddress,"` TockenLength int `json:"TockenLength,int"` ExpirationTime int `json:"ExpirationTime,int"` }
Config is a struct for configuring session manager.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager stores connection to redis database.
func InitConnSM ¶
func InitConnSM(cfg Config) (*SessionManager, error)
InitConnSM initiates connection to redis database. It returns struct that implements model.SM interface used by API to interact with sessions.
func (*SessionManager) CheckSession ¶
CheckSession checks if session with such ID exists in database.
func (*SessionManager) CreateSession ¶
CreateSession creates new session in database.
func (*SessionManager) DeleteSession ¶
func (sm *SessionManager) DeleteSession(in *model.SessionID) error
DeleteSession deletes session with such ID.
func (*SessionManager) IsConnected ¶
func (sm *SessionManager) IsConnected() bool
IsConnected checks if connection is active
func (*SessionManager) TryReconnect ¶
func (sm *SessionManager) TryReconnect() error
TryReconnect reconnects to redis