Documentation
¶
Index ¶
- func NewRedisClient(opt *redis.Options) (*redis.Client, error)
- type AccountSessions
- type Metrics
- type RegistrationRepository
- func (r *RegistrationRepository) DeleteAccount(ctx context.Context, email string) (err error)
- func (r *RegistrationRepository) GetAccount(ctx context.Context, email string) (account models.RegisteredAccount, err error)
- func (r *RegistrationRepository) IsAccountExist(ctx context.Context, email string) (inCache bool, err error)
- func (r *RegistrationRepository) PingContext(ctx context.Context) error
- func (r *RegistrationRepository) SetAccount(ctx context.Context, email string, account models.RegisteredAccount, ...) (err error)
- func (r *RegistrationRepository) Shutdown()
- type SessionsRepository
- func (r *SessionsRepository) GetSession(ctx context.Context, sessionID string) (session models.Session, err error)
- func (r *SessionsRepository) GetSessionsForAccount(ctx context.Context, accountID string) (sessions map[string]*models.SessionInfo, err error)
- func (r *SessionsRepository) GetSessionsIds(ctx context.Context, accountID string) (sessionsIds []string, err error)
- func (r *SessionsRepository) PingContext(ctx context.Context) error
- func (r *SessionsRepository) SetSession(ctx context.Context, session *models.Session, ttl time.Duration) (err error)
- func (r *SessionsRepository) Shutdown()
- func (r *SessionsRepository) TerminateAllSessions(ctx context.Context, accountID string) (err error)
- func (r *SessionsRepository) TerminateSessions(ctx context.Context, sessionsIds []string, accountID string) (err error)
- func (r *SessionsRepository) UpdateLastActivityForSession(ctx context.Context, cachedSession *models.Session, lastActivityTime time.Time, ...) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRedisClient ¶
func NewRedisClient(opt *redis.Options) (*redis.Client, error)
Types ¶
type AccountSessions ¶
type AccountSessions struct {
Sessions []string `json:"sessions"`
}
type RegistrationRepository ¶
type RegistrationRepository struct {
// contains filtered or unexported fields
}
func NewRedisRegistrationRepository ¶
func NewRedisRegistrationRepository(opt *redis.Options, logger *logrus.Logger, metrics Metrics) (*RegistrationRepository, error)
NewRedisRegistrationRepository initializes a new instance of RegistrationRepository with the provided options and logger.
func (*RegistrationRepository) DeleteAccount ¶
func (r *RegistrationRepository) DeleteAccount(ctx context.Context, email string) (err error)
DeleteAccount deletes the account information associated with the specified email from the repository.
func (*RegistrationRepository) GetAccount ¶
func (r *RegistrationRepository) GetAccount(ctx context.Context, email string) (account models.RegisteredAccount, err error)
GetAccount retrieves the cached account information for the specified email from the repository. It returns the cached account data and any encountered error during retrieval.
func (*RegistrationRepository) IsAccountExist ¶
func (r *RegistrationRepository) IsAccountExist(ctx context.Context, email string) (inCache bool, err error)
IsAccountExist checks if the provided email account is present in the repository.
func (*RegistrationRepository) PingContext ¶
func (r *RegistrationRepository) PingContext(ctx context.Context) error
func (*RegistrationRepository) SetAccount ¶
func (r *RegistrationRepository) SetAccount(ctx context.Context, email string, account models.RegisteredAccount, ttl time.Duration) (err error)
SetAccount caches the provided account information with the specified email in the repository. It marshals the account data into JSON and sets it in the repository with the specified TTL.
func (*RegistrationRepository) Shutdown ¶
func (r *RegistrationRepository) Shutdown()
Shutdown gracefully shuts down the registration repository.
type SessionsRepository ¶
type SessionsRepository struct {
// contains filtered or unexported fields
}
func NewSessionsRepository ¶
func NewSessionsRepository(opt *redis.Options, logger *logrus.Logger, metrics Metrics, ) (*SessionsRepository, error)
NewSessionsRepository creates a new session repository using the provided Redis options, logger, and session TTL. It initializes two Redis clients for session and account session caching, and verifies the connection to each Redis instance.
func (*SessionsRepository) GetSession ¶
func (r *SessionsRepository) GetSession(ctx context.Context, sessionID string) (session models.Session, err error)
GetSession retrieves the session repository for a given session ID from the Redis repository. It retrieves the session data from the repository, and unmarshals it into a models.Session. If the session data is not found in the repository, it returns an error indicating that the session was not found.
func (*SessionsRepository) GetSessionsForAccount ¶
func (r *SessionsRepository) GetSessionsForAccount(ctx context.Context, accountID string) (sessions map[string]*models.SessionInfo, err error)
GetSessionsForAccount retrieves the sessions associated with the specified account from the Redis repository.
func (*SessionsRepository) GetSessionsIds ¶
func (*SessionsRepository) PingContext ¶
func (r *SessionsRepository) PingContext(ctx context.Context) error
func (*SessionsRepository) SetSession ¶
func (*SessionsRepository) Shutdown ¶
func (r *SessionsRepository) Shutdown()
Shutdown gracefully shuts down the sessions repository by closing the Redis client for session caching.
func (*SessionsRepository) TerminateAllSessions ¶
func (r *SessionsRepository) TerminateAllSessions(ctx context.Context, accountID string) (err error)
func (*SessionsRepository) TerminateSessions ¶
func (*SessionsRepository) UpdateLastActivityForSession ¶
func (r *SessionsRepository) UpdateLastActivityForSession(ctx context.Context, cachedSession *models.Session, lastActivityTime time.Time, ttl time.Duration) (err error)
UpdateLastActivityForSession updates the last activity time for a cached session in the Redis repository. It updates the LastActivity field of the cached session, and then caches the updated session.