mem

package
v2.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ErrorNotFound general not found error
	ErrorNotFound = Error("not found")
	// ErrorEmptyAppID means appID params is empty
	ErrorEmptyAppID = Error("Empty appID param")
	// ErrorInactiveApp means app is inactive
	ErrorInactiveApp = Error("App is inactive")
)

Variables

This section is empty.

Functions

func NewAppStorage

func NewAppStorage() (model.AppStorage, error)

NewAppStorage creates new in-memory AppStorage implementation.

func NewConnectionTester

func NewConnectionTester() model.ConnectionTester

func NewInviteStorage

func NewInviteStorage() (model.InviteStorage, error)

NewInviteStorage creates an in-memory invite storage.

func NewManagementKeysStorage added in v2.4.4

func NewManagementKeysStorage() (model.ManagementKeysStorage, error)

NewKeysManagementStorage creates an in-memory management keys storage.

func NewMapOverlayFS

func NewMapOverlayFS(base fs.FS, files map[string][]byte) fs.FS

func NewSessionStorage

func NewSessionStorage() model.SessionStorage

NewSessionStorage creates an in-memory session storage.

func NewTokenBlacklist

func NewTokenBlacklist() (model.TokenBlacklist, error)

NewTokenBlacklist creates an in-memory token storage.

func NewTokenStorage

func NewTokenStorage() (model.TokenStorage, error)

NewTokenStorage creates an in-memory token storage.

func NewUserStorage

func NewUserStorage() (model.UserStorage, error)

NewUserStorage creates and inits in-memory user storage. Use it only for test purposes and in CI, all data is wiped on exit.

func NewVerificationCodeStorage

func NewVerificationCodeStorage() (model.VerificationCodeStorage, error)

NewVerificationCodeStorage creates and inits in-memory verification code storage.

Types

type AppStorage

type AppStorage struct {
	// contains filtered or unexported fields
}

AppStorage is a fully functional app storage.

func (*AppStorage) ActiveAppByID

func (as *AppStorage) ActiveAppByID(appID string) (model.AppData, error)

ActiveAppByID returns app by id only if it's active.

func (*AppStorage) AppByID

func (as *AppStorage) AppByID(id string) (model.AppData, error)

AppByID returns app by ID from the in-memory storage.

func (*AppStorage) Close

func (as *AppStorage) Close()

Close clears storage.

func (*AppStorage) CreateApp

func (as *AppStorage) CreateApp(app model.AppData) (model.AppData, error)

CreateApp creates new app in memory.

func (*AppStorage) DeleteApp

func (as *AppStorage) DeleteApp(id string) error

DeleteApp does nothing here.

func (*AppStorage) DisableApp

func (as *AppStorage) DisableApp(app model.AppData) error

DisableApp deletes app from in-memory storage.

func (*AppStorage) FetchApps

func (as *AppStorage) FetchApps(filterString string) ([]model.AppData, error)

FetchApps fetches apps which name satisfies provided filterString. Supports pagination.

func (*AppStorage) ImportJSON

func (as *AppStorage) ImportJSON(data []byte, cleanOldData bool) error

ImportJSON imports data from JSON.

func (*AppStorage) TestDatabaseConnection

func (as *AppStorage) TestDatabaseConnection() error

TestDatabaseConnection is always optimistic about the database connection.

func (*AppStorage) UpdateApp

func (as *AppStorage) UpdateApp(appID string, newApp model.AppData) (model.AppData, error)

UpdateApp updates app in the storage.

type ConnectionTester

type ConnectionTester struct{}

func (*ConnectionTester) Connect

func (ct *ConnectionTester) Connect() error

type Error

type Error string

Error - domain level error type

func (Error) Error

func (e Error) Error() string

Error - implementation of std.Error protocol

type InviteStorage

type InviteStorage struct {
	// contains filtered or unexported fields
}

InviteStorage is an in-memory invite storage. Please do not use it in production, it has no disk swap or persistent cache support.

func (*InviteStorage) ArchiveAllByEmail

func (is *InviteStorage) ArchiveAllByEmail(email string) error

ArchiveAllByEmail invalidates all invites by email.

func (*InviteStorage) ArchiveByID

func (is *InviteStorage) ArchiveByID(id string) error

ArchiveByID invalidates specific invite by its ID.

func (*InviteStorage) Close

func (is *InviteStorage) Close()

Close clears storage.

func (*InviteStorage) GetAll

func (is *InviteStorage) GetAll(withArchived bool, skip, limit int) ([]model.Invite, int, error)

GetAll returns all active invites by default. To get an invalid invites need to set withInvalid argument to true.

func (*InviteStorage) GetByEmail

func (is *InviteStorage) GetByEmail(email string) (model.Invite, error)

GetByEmail returns valid and not expired invite by email.

func (*InviteStorage) GetByID

func (is *InviteStorage) GetByID(id string) (model.Invite, error)

GetByID returns invite by its ID.

func (*InviteStorage) Save

func (is *InviteStorage) Save(email, inviteToken, role, appID, createdBy string, expiresAt time.Time) error

Save creates and saves new invite to a database.

type ManagementKeysStorage added in v2.4.4

type ManagementKeysStorage struct {
	// contains filtered or unexported fields
}

func (*ManagementKeysStorage) ChangeScopesForKey added in v2.4.4

func (ms *ManagementKeysStorage) ChangeScopesForKey(ctx context.Context, id string, scopes []string) (model.ManagementKey, error)

func (*ManagementKeysStorage) CreateKey added in v2.4.4

func (ms *ManagementKeysStorage) CreateKey(ctx context.Context, name string, scopes []string) (model.ManagementKey, error)

func (*ManagementKeysStorage) DisableKey added in v2.4.4

func (*ManagementKeysStorage) GetKey added in v2.4.4

func (*ManagementKeysStorage) GeyAllKeys added in v2.4.4

func (ms *ManagementKeysStorage) GeyAllKeys(ctx context.Context) ([]model.ManagementKey, error)

func (*ManagementKeysStorage) ImportJSON added in v2.4.5

func (ms *ManagementKeysStorage) ImportJSON(data []byte, cleanOldData bool) error

func (*ManagementKeysStorage) RenameKey added in v2.4.4

func (ms *ManagementKeysStorage) RenameKey(ctx context.Context, id, name string) (model.ManagementKey, error)

func (*ManagementKeysStorage) UseKey added in v2.4.4

type TokenBlacklist

type TokenBlacklist struct {
	// contains filtered or unexported fields
}

TokenBlacklist is an in-memory token storage. Please do not use it in production, it has no disk swap or persistent cache support.

func (*TokenBlacklist) Add

func (tb *TokenBlacklist) Add(token string) error

Add blacklists token.

func (*TokenBlacklist) Close

func (tb *TokenBlacklist) Close()

Close clears storage.

func (*TokenBlacklist) IsBlacklisted

func (tb *TokenBlacklist) IsBlacklisted(token string) bool

IsBlacklisted returns true if the token is blacklisted.

type TokenStorage

type TokenStorage struct {
	// contains filtered or unexported fields
}

TokenStorage is an in-memory token storage. Please do not use it in production, it has no disk swap or persistent cache support.

func (*TokenStorage) Close

func (ts *TokenStorage) Close()

Close clears storage.

func (*TokenStorage) DeleteToken

func (ts *TokenStorage) DeleteToken(token string) error

DeleteToken removes token from memory storage. Actually, just marks it as deleted.

func (*TokenStorage) HasToken

func (ts *TokenStorage) HasToken(token string) bool

HasToken returns true if the token is present in the storage.

func (*TokenStorage) SaveToken

func (ts *TokenStorage) SaveToken(token string) error

SaveToken saves token in memory.

type UserStorage

type UserStorage struct {
	// contains filtered or unexported fields
}

UserStorage is an in-memory user storage .

func (*UserStorage) AddNewUser

func (us *UserStorage) AddNewUser(user model.User, password string) (model.User, error)

AddNewUser adds new user to the database.

func (*UserStorage) AddUserWithFederatedID

func (us *UserStorage) AddUserWithFederatedID(user model.User, provider string, id, role string) (model.User, error)

AddUserWithFederatedID returns randomly generated user.

func (*UserStorage) AddUserWithPassword

func (us *UserStorage) AddUserWithPassword(user model.User, password, role string, isAnonymous bool) (model.User, error)

AddUserWithPassword creates new user and saves it in the database.

func (*UserStorage) AllDeviceTokens

func (us *UserStorage) AllDeviceTokens(userID string) ([]string, error)

TODO: implement get all device tokens logic

func (*UserStorage) AttachDeviceToken

func (us *UserStorage) AttachDeviceToken(id, token string) error

AttachDeviceToken does nothing here.

func (*UserStorage) CheckPassword

func (us *UserStorage) CheckPassword(id, password string) error

CheckPassword does nothig here.

func (*UserStorage) Close

func (us *UserStorage) Close()

Close does nothing here.

func (*UserStorage) DeleteUser

func (us *UserStorage) DeleteUser(id string) error

DeleteUser does nothing here.

func (*UserStorage) DetachDeviceToken

func (us *UserStorage) DetachDeviceToken(token string) error

DetachDeviceToken does nothing here.

func (*UserStorage) FetchUsers

func (us *UserStorage) FetchUsers(filterString string, skip, limit int) ([]model.User, int, error)

FetchUsers returns randomly generated user enclosed in slice.

func (*UserStorage) ImportJSON

func (us *UserStorage) ImportJSON(data []byte, clearOldData bool) error

ImportJSON imports data from JSON.

func (*UserStorage) ResetPassword

func (us *UserStorage) ResetPassword(id, password string) error

ResetPassword does nothing here.

func (*UserStorage) UpdateLoginMetadata

func (us *UserStorage) UpdateLoginMetadata(userID string)

UpdateLoginMetadata does nothing here.

func (*UserStorage) UpdateUser

func (us *UserStorage) UpdateUser(userID string, newUser model.User) (model.User, error)

UpdateUser returns what it receives.

func (*UserStorage) UserByEmail

func (us *UserStorage) UserByEmail(email string) (model.User, error)

UserByEmail returns randomly generated user.

func (*UserStorage) UserByFederatedID

func (us *UserStorage) UserByFederatedID(provider string, id string) (model.User, error)

UserByFederatedID returns randomly generated user.

func (*UserStorage) UserByID

func (us *UserStorage) UserByID(id string) (model.User, error)

UserByID returns randomly generated user.

func (*UserStorage) UserByPhone

func (us *UserStorage) UserByPhone(phone string) (model.User, error)

UserByPhone returns randomly generated user.

func (*UserStorage) UserBySocialID

func (us *UserStorage) UserBySocialID(id string) (model.User, error)

UserBySocialID returns randomly generated user.

func (*UserStorage) UserByUsername

func (us *UserStorage) UserByUsername(username string) (model.User, error)

UserByUsername returns randomly generated user.

type VerificationCodeStorage

type VerificationCodeStorage struct{}

VerificationCodeStorage implements verification code storage interface.

func (*VerificationCodeStorage) Close

func (vcs *VerificationCodeStorage) Close()

Close does nothing here.

func (*VerificationCodeStorage) CreateVerificationCode

func (vcs *VerificationCodeStorage) CreateVerificationCode(phone, code string) error

CreateVerificationCode is always optimistic.

func (*VerificationCodeStorage) IsVerificationCodeFound

func (vcs *VerificationCodeStorage) IsVerificationCodeFound(phone, code string) (bool, error)

IsVerificationCodeFound is always optimistic.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL