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) Normalize() *Options
- func (o *Options) Validate() error
- func (o *Options) WithMaxSessionAgeTime(maxAgeTime time.Duration) *Options
- func (o *Options) WithMaxSessionInactivityTime(maxInactivityTime time.Duration) *Options
- func (o *Options) WithMaxSessions(maxSessions int) *Options
- func (o *Options) WithRandSource(src io.Reader) *Options
- func (o *Options) WithSessionGuardCheckInterval(interval time.Duration) *Options
- func (o *Options) WithTimeout(timeout time.Duration) *Options
- type PaginatedDocumentReader
- type Session
- func (s *Session) CloseDocumentReaders() error
- func (s *Session) DeleteDocumentReader(searchID string) error
- func (s *Session) GetCreationTime() time.Time
- func (s *Session) GetDatabase() database.DB
- func (s *Session) GetDocumentReader(searchID string) (*PaginatedDocumentReader, error)
- func (s *Session) GetDocumentReadersCount() int
- func (s *Session) GetID() string
- func (s *Session) GetLastActivityTime() time.Time
- func (s *Session) GetTransaction(transactionID string) (transactions.Transaction, error)
- func (s *Session) GetUser() *auth.User
- func (s *Session) NewTransaction(ctx context.Context, opts *sql.TxOptions) (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) SetPaginatedDocumentReader(searchID string, reader *PaginatedDocumentReader)
- func (s *Session) UpdatePaginatedDocumentReader(searchID string, lastPage uint32, lastPageSize uint32) error
Constants ¶
View Source
const DefaultMaxDocumentReadersCacheSize = 1
DefaultMaxDocumentReadersCacheSize is the default maximum number of document readers to keep in cache
Variables ¶
View Source
var ErrCantCreateSession = errors.New("can not create new session")
View Source
var ErrCantCreateSessionID = fmt.Errorf("%w: generation of session id failed", ErrCantCreateSession)
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 = fmt.Errorf("%w: max sessions number reached", ErrCantCreateSession)
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 (
ErrPaginatedDocumentReaderNotFound = errors.New("document reader not found")
)
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(ctx context.Context, 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 // Max number of simultaneous sessions MaxSessions int // Random number generator RandSource io.Reader }
func DefaultOptions ¶
func DefaultOptions() *Options
func (*Options) WithMaxSessionAgeTime ¶
func (*Options) WithMaxSessionInactivityTime ¶
func (*Options) WithMaxSessions ¶ added in v1.3.1
func (*Options) WithRandSource ¶ added in v1.3.1
func (*Options) WithSessionGuardCheckInterval ¶
type PaginatedDocumentReader ¶ added in v1.5.0
type PaginatedDocumentReader struct { Reader document.DocumentReader // reader to read from Query *protomodel.Query LastPageNumber uint32 // last read page number LastPageSize uint32 // number of items per page }
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func (*Session) CloseDocumentReaders ¶ added in v1.5.0
func (*Session) DeleteDocumentReader ¶ added in v1.5.0
func (*Session) GetCreationTime ¶
func (*Session) GetDatabase ¶
func (*Session) GetDocumentReader ¶ added in v1.5.0
func (s *Session) GetDocumentReader(searchID string) (*PaginatedDocumentReader, error)
func (*Session) GetDocumentReadersCount ¶ added in v1.5.0
func (*Session) GetLastActivityTime ¶
func (*Session) GetTransaction ¶
func (s *Session) GetTransaction(transactionID string) (transactions.Transaction, error)
func (*Session) NewTransaction ¶
func (s *Session) NewTransaction(ctx context.Context, opts *sql.TxOptions) (transactions.Transaction, error)
func (*Session) RemoveTransaction ¶
func (*Session) RollbackTransactions ¶
func (*Session) SetDatabase ¶
func (*Session) SetLastActivityTime ¶
func (*Session) SetPaginatedDocumentReader ¶ added in v1.5.0
func (s *Session) SetPaginatedDocumentReader(searchID string, reader *PaginatedDocumentReader)
Click to show internal directories.
Click to hide internal directories.