mem

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 7 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 NewInviteStorage added in v1.2.4

func NewInviteStorage() (model.InviteStorage, error)

NewInviteStorage creates an in-memory invite 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, skip, limit int) ([]model.AppData, int, error)

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

func (*AppStorage) ImportJSON

func (as *AppStorage) ImportJSON(data []byte) 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 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 added in v1.2.4

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 added in v1.2.4

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

ArchiveAllByEmail invalidates all invites by email.

func (*InviteStorage) ArchiveByID added in v1.2.4

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

ArchiveByID invalidates specific invite by its ID.

func (*InviteStorage) Close added in v1.2.4

func (is *InviteStorage) Close()

Close clears storage.

func (*InviteStorage) GetAll added in v1.2.4

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 added in v1.2.4

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

GetByEmail returns valid and not expired invite by email.

func (*InviteStorage) GetByID added in v1.2.4

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

GetByID returns invite by its ID.

func (*InviteStorage) Save added in v1.2.4

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

Save creates and saves new invite to a database.

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{}

UserStorage is an in-memory user storage .

func (*UserStorage) AddUserByNameAndPassword

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

AddUserByNameAndPassword returns randomly generated user.

func (*UserStorage) AddUserByPhone

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

AddUserByPhone returns randomly generated user.

func (*UserStorage) AddUserWithFederatedID

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

AddUserWithFederatedID returns randomly generated user.

func (*UserStorage) AttachDeviceToken

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

AttachDeviceToken does nothing 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) IDByName

func (us *UserStorage) IDByName(name string) (string, error)

IDByName returns random id.

func (*UserStorage) ImportJSON

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

ImportJSON imports data from JSON.

func (*UserStorage) RequestScopes

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

RequestScopes always returns requested scopes.

func (*UserStorage) ResetPassword

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

ResetPassword does nothing here.

func (*UserStorage) Scopes

func (us *UserStorage) Scopes() []string

Scopes returns supported scopes, could be static data of database.

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 model.FederatedIdentityProvider, 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) UserByNamePassword

func (us *UserStorage) UserByNamePassword(name, password string) (model.User, error)

UserByNamePassword 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) UserExists

func (us *UserStorage) UserExists(name string) bool

UserExists always returns true.

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