Documentation ¶
Index ¶
- Constants
- Variables
- func GetSessionIDFromContext(ctx context.Context) (string, error)
- func GetTransactionIDFromContext(ctx context.Context) (string, error)
- func NewManager(options *Options) (*manager, error)
- type Manager
- type Options
- func (o *Options) WithMaxSessionAgeTime(maxAgeTime time.Duration) *Options
- func (o *Options) WithMaxSessionInactivityTime(maxInactivityTime time.Duration) *Options
- func (o *Options) WithSessionGuardCheckInterval(interval time.Duration) *Options
- func (o *Options) WithTimeout(timeout time.Duration) *Options
- type Session
- func (s *Session) GetCreationTime() time.Time
- func (s *Session) GetDatabase() database.DB
- func (s *Session) GetID() string
- func (s *Session) GetLastActivityTime() time.Time
- func (s *Session) GetReadWriteTxOngoing() bool
- func (s *Session) GetStatus() Status
- func (s *Session) GetTransaction(transactionID string) (transactions.Transaction, error)
- func (s *Session) GetUser() *auth.User
- func (s *Session) NewTransaction(mode schema.TxMode) (transactions.Transaction, error)
- func (s *Session) RemoveTransaction(transactionID string) error
- func (s *Session) RollbackTransactions() error
- func (s *Session) SetDatabase(db database.DB)
- func (s *Session) SetLastActivityTime(t time.Time)
- func (s *Session) SetReadWriteTxOngoing(b bool)
- type Status
Constants ¶
View Source
const MaxSessions = 100
Variables ¶
View Source
var ErrGuardAlreadyRunning = errors.New("session guard already launched")
View Source
var ErrGuardNotRunning = errors.New("session guard not running")
View Source
var ErrInvalidOptionsProvided = errors.New("invalid options provided")
View Source
var ErrMaxSessionsReached = errors.New("max sessions reached")
View Source
var ErrNoSessionAuthDataProvided = errors.New("no session auth data provided").WithCode(errors.CodInvalidAuthorizationSpecification)
View Source
var ErrNoSessionIDPresent = errors.New("no sessionID provided").WithCode(errors.CodInvalidAuthorizationSpecification)
View Source
var ErrNoTransactionAuthDataProvided = errors.New("no transaction auth data provided").WithCode(errors.CodInvalidAuthorizationSpecification)
View Source
var ErrNoTransactionIDPresent = errors.New("no transactionID provided").WithCode(errors.CodInvalidAuthorizationSpecification)
View Source
var ErrOngoingReadWriteTx = errors.New("only 1 read write transaction supported at once").WithCode(errors.CodSqlserverRejectedEstablishmentOfSqlSession)
View Source
var ErrReadOnlyTXNotAllowed = errors.New("read only transaction not allowed")
View Source
var ErrSessionAlreadyPresent = errors.New("session already present").WithCode(errors.CodInternalError)
View Source
var ErrSessionNotFound = errors.New("no session found").WithCode(errors.CodInvalidParameterValue)
View Source
var ErrTransactionNotFound = transactions.ErrTransactionNotFound
View Source
var ErrWriteOnlyTXNotAllowed = errors.New("write only transaction not allowed")
Functions ¶
func NewManager ¶
Types ¶
type Manager ¶
type Manager interface { NewSession(user *auth.User, db database.DB) (*Session, error) SessionPresent(sessionID string) bool DeleteSession(sessionID string) error UpdateSessionActivityTime(sessionID string) StartSessionsGuard() error StopSessionsGuard() error GetSession(sessionID string) (*Session, error) SessionCount() int GetTransactionFromContext(ctx context.Context) (transactions.Transaction, error) GetSessionFromContext(ctx context.Context) (*Session, error) DeleteTransaction(transactions.Transaction) error CommitTransaction(transaction transactions.Transaction) ([]*sql.SQLTx, error) RollbackTransaction(transaction transactions.Transaction) error }
type Options ¶
type Options struct { SessionGuardCheckInterval time.Duration // MaxSessionInactivityTime is a duration for the amount of time after which an idle session would be closed by the server MaxSessionInactivityTime time.Duration // MaxSessionAgeTime is a duration for the maximum amount of time a session may exist before it will be closed by the server MaxSessionAgeTime time.Duration // Timeout the server waits for a duration of Timeout and if no activity is seen even after that the session is closed Timeout time.Duration }
func DefaultOptions ¶
func DefaultOptions() *Options
func (*Options) WithMaxSessionAgeTime ¶
func (*Options) WithMaxSessionInactivityTime ¶
func (*Options) WithSessionGuardCheckInterval ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func (*Session) GetCreationTime ¶
func (*Session) GetDatabase ¶
func (*Session) GetLastActivityTime ¶
func (*Session) GetReadWriteTxOngoing ¶
func (*Session) GetTransaction ¶
func (s *Session) GetTransaction(transactionID string) (transactions.Transaction, error)
func (*Session) NewTransaction ¶
func (s *Session) NewTransaction(mode schema.TxMode) (transactions.Transaction, error)
func (*Session) RemoveTransaction ¶
func (*Session) RollbackTransactions ¶
func (*Session) SetDatabase ¶
func (*Session) SetLastActivityTime ¶
func (*Session) SetReadWriteTxOngoing ¶ added in v1.2.1
Click to show internal directories.
Click to hide internal directories.