Documentation ¶
Index ¶
- type Driver
- func (h *Driver) AddGPGKey(key models.GPGKey) (string, bool, error)
- func (h *Driver) AddGPGKeys(keys []models.GPGKey) ([]string, []bool, error)
- func (h *Driver) AddUser(um models.User) (string, error)
- func (h *Driver) AddUserToken(ut models.UserToken) (string, error)
- func (h *Driver) DeleteGPGKey(key models.GPGKey) error
- func (h *Driver) FetchGPGKeyByFingerprint(fingerprint string) (*models.GPGKey, error)
- func (h *Driver) FetchGPGKeysWithoutSubKeys() (res []models.GPGKey, err error)
- func (h *Driver) FindGPGKeyByEmail(email string, pageStart, pageEnd int) (res []models.GPGKey, err error)
- func (h *Driver) FindGPGKeyByFingerPrint(fingerPrint string, pageStart, pageEnd int) ([]models.GPGKey, error)
- func (h *Driver) FindGPGKeyByName(name string, pageStart, pageEnd int) ([]models.GPGKey, error)
- func (h *Driver) FindGPGKeyByValue(value string, pageStart, pageEnd int) ([]models.GPGKey, error)
- func (h *Driver) FinishCursor() error
- func (h *Driver) GetUser(username string) (um *models.User, err error)
- func (h *Driver) GetUserToken(token string) (ut *models.UserToken, err error)
- func (h *Driver) HealthCheck() error
- func (h *Driver) InitCursor() error
- func (h *Driver) InvalidateUserTokens() (int, error)
- func (h *Driver) NextGPGKey(key *models.GPGKey) bool
- func (h *Driver) NextUser(user *models.User) bool
- func (h *Driver) NumGPGKeys() (int, error)
- func (h *Driver) RemoveUserToken(token string) (err error)
- func (h *Driver) Setup(client rediser, maxLocalObjects int, localObjectTTL time.Duration) error
- func (h *Driver) UpdateGPGKey(key models.GPGKey) (err error)
- func (h *Driver) UpdateUser(um models.User) error
- type ProxiedGPGRepository
- type ProxiedHandler
- type ProxiedHealthChecker
- type ProxiedMigrationHandler
- type ProxiedUserRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is a database handler proxy for caching
func MakeRedisDriver ¶
func MakeRedisDriver(dbh ProxiedHandler, log slog.Instance) *Driver
MakeRedisDriver creates a Redis Caching layer for the specified handler It also implements the Token mechanics (it does not pass to the underlying handler)
func (*Driver) AddGPGKey ¶
AddGPGKey adds a GPG Key to the database or update an existing one by fingerprint Returns generated id / hasBeenAdded / error
func (*Driver) AddGPGKeys ¶
AddGPGKey adds a list GPG Key to the database or update an existing one by fingerprint Same as AddGPGKey but in a single transaction
func (*Driver) AddUserToken ¶
AddUserToken adds a new user token to be valid and returns its token ID
func (*Driver) DeleteGPGKey ¶
DeleteGPGKey deletes the specified GPG key by using it's ID
func (*Driver) FetchGPGKeyByFingerprint ¶
FetchGPGKeyByFingerprint fetch a GPG Key by its fingerprint
func (*Driver) FetchGPGKeysWithoutSubKeys ¶
FetchGPGKeysWithoutSubKeys fetch all keys that does not have a subkey This query is not implemented on PostgreSQL
func (*Driver) FindGPGKeyByEmail ¶
func (h *Driver) FindGPGKeyByEmail(email string, pageStart, pageEnd int) (res []models.GPGKey, err error)
FindGPGKeyByEmail find all keys that has a underlying UID that contains that email
func (*Driver) FindGPGKeyByFingerPrint ¶
func (h *Driver) FindGPGKeyByFingerPrint(fingerPrint string, pageStart, pageEnd int) ([]models.GPGKey, error)
FindGPGKeyByFingerPrint find all keys that has a fingerprint that matches the specified fingerprint
func (*Driver) FindGPGKeyByName ¶
FindGPGKeyByName find all keys that has a underlying UID that contains that name
func (*Driver) FindGPGKeyByValue ¶
FindGPGKeyByValue find all keys that has a underlying UID that contains that email, name or fingerprint specified by value
func (*Driver) FinishCursor ¶
func (*Driver) GetUserToken ¶
GetUserToken fetch a UserToken object by the specified token
func (*Driver) HealthCheck ¶
HealthCheck returns nil if everything is OK with the handler
func (*Driver) InitCursor ¶
func (*Driver) InvalidateUserTokens ¶
InvalidateUserTokens removes all user tokens that had been already expired Does nothing on REDIS due automatic expiration using TTL
func (*Driver) NumGPGKeys ¶
func (*Driver) RemoveUserToken ¶
RemoveUserToken removes a user token from the database
func (*Driver) UpdateGPGKey ¶
UpdateGPGKey updates the specified GPG key by using it's ID
type ProxiedGPGRepository ¶
type ProxiedGPGRepository interface { // AddGPGKey adds a GPG Key to the database or update an existing one by fingerprint // Returns generated id / hasBeenAdded / error AddGPGKey(key models.GPGKey) (string, bool, error) // AddGPGKey adds a list GPG Key to the database or update an existing one by fingerprint // Same as AddGPGKey but in a single transaction AddGPGKeys(keys []models.GPGKey) (ids []string, addeds []bool, err error) // FindGPGKeyByEmail find all keys that has a underlying UID that contains that email FindGPGKeyByEmail(email string, pageStart, pageEnd int) ([]models.GPGKey, error) // FindGPGKeyByFingerPrint find all keys that has a fingerprint that matches the specified fingerprint FindGPGKeyByFingerPrint(fingerPrint string, pageStart, pageEnd int) ([]models.GPGKey, error) // FindGPGKeyByValue find all keys that has a underlying UID that contains that email, name or fingerprint specified by value FindGPGKeyByValue(value string, pageStart, pageEnd int) ([]models.GPGKey, error) // FindGPGKeyByName find all keys that has a underlying UID that contains that name FindGPGKeyByName(name string, pageStart, pageEnd int) ([]models.GPGKey, error) // FetchGPGKeyByFingerprint fetch a GPG Key by its fingerprint FetchGPGKeyByFingerprint(fingerprint string) (*models.GPGKey, error) // FetchGPGKeysWithoutSubKeys fetch all keys that does not have a subkey // This query is not implemented on PostgreSQL FetchGPGKeysWithoutSubKeys() (res []models.GPGKey, err error) // DeleteGPGKey deletes the specified GPG key by using it's ID DeleteGPGKey(key models.GPGKey) error // UpdateGPGKey updates the specified GPG key by using it's ID UpdateGPGKey(key models.GPGKey) (err error) }
ProxiedUserRepository a proxy to a GPG Repository
type ProxiedHandler ¶
type ProxiedHandler interface { ProxiedUserRepository ProxiedGPGRepository ProxiedHealthChecker ProxiedMigrationHandler }
ProxiedHandler is a handler to be proxied by REDIS caching
type ProxiedHealthChecker ¶
type ProxiedHealthChecker interface { // HealthCheck returns nil if everything is OK with the handler HealthCheck() error }
ProxiedUserRepository a proxy to a Health Checker
type ProxiedMigrationHandler ¶
type ProxiedMigrationHandler interface { InitCursor() error FinishCursor() error NextGPGKey(key *models.GPGKey) bool NextUser(user *models.User) bool NumGPGKeys() (int, error) }
ProxiedMigrationHandler
type ProxiedUserRepository ¶
type ProxiedUserRepository interface { GetUser(username string) (um *models.User, err error) // AddUserToken adds a new user token to be valid and returns its token ID AddUserToken(ut models.UserToken) (string, error) // RemoveUserToken removes a user token from the database RemoveUserToken(token string) (err error) // GetUserToken fetch a UserToken object by the specified token GetUserToken(token string) (ut *models.UserToken, err error) // InvalidateUserTokens removes all user tokens that had been already expired InvalidateUserTokens() (int, error) AddUser(um models.User) (string, error) UpdateUser(um models.User) error }
ProxiedUserRepository a proxy to a User Repository