store

package
v0.0.0-...-2418929 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgresqlClient

func NewPostgresqlClient(connStr string) *sql.DB

NewPostgresqlClient creates a new db client object

func NewRedisClient

func NewRedisClient(addr string, password string) redis.Client

NewRedisClient creates a new redis client object

Types

type DiskStore

type DiskStore struct{}

DiskStore is a storage engine that writes to the disk

func NewDiskStore

func NewDiskStore() *DiskStore

NewDiskStore will instantiate the disk storage

func (DiskStore) DeleteUser

func (s DiskStore) DeleteUser(id string) bool

func (DiskStore) GetUser

func (s DiskStore) GetUser(id string) *User

GetUser will load a user from disk

func (DiskStore) Ping

func (s DiskStore) Ping(ctx context.Context) error

Ping will check if the connection works right

func (DiskStore) WriteUser

func (s DiskStore) WriteUser(user User)

WriteUser will write a user object to disk

type PostgresqlStore

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

PostgresqlStore is a storage engine that writes to postgres

func NewPostgresqlStore

func NewPostgresqlStore(db *sql.DB) PostgresqlStore

NewPostgresqlStore creates new store

func (PostgresqlStore) DeleteUser

func (s PostgresqlStore) DeleteUser(id string) bool

TODO: Not Implemented

func (PostgresqlStore) GetUser

func (s PostgresqlStore) GetUser(id string) *User

GetUser will load a user from postgres

func (PostgresqlStore) Ping

func (s PostgresqlStore) Ping(ctx context.Context) error

Ping will check if the connection works right

func (PostgresqlStore) WriteUser

func (s PostgresqlStore) WriteUser(user User)

WriteUser will write a user object to postgres

type RedisStore

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

RedisStore is a storage engine that writes to redis

func NewRedisStore

func NewRedisStore(client redis.Client) RedisStore

NewRedisStore creates new store

func (RedisStore) DeleteUser

func (s RedisStore) DeleteUser(id string) bool

TODO: Not Implemented

func (RedisStore) GetUser

func (s RedisStore) GetUser(id string) *User

GetUser will load a user from redis

func (RedisStore) Ping

func (s RedisStore) Ping(ctx context.Context) error

Ping will check if the connection works right

func (RedisStore) WriteUser

func (s RedisStore) WriteUser(user User)

WriteUser will write a user object to redis

type Store

type Store interface {
	WriteUser(user User)
	GetUser(id string) *User
	DeleteUser(id string) bool
	Ping(ctx context.Context) error
}

Store is the interface for All the store types

type User

type User struct {
	ID           string
	Username     string
	AccessToken  string
	RefreshToken string
	Updated      time.Time
	// contains filtered or unexported fields
}

User object

func NewUser

func NewUser(username, accessToken, refreshToken string, store store) User

NewUser creates a new user object

func (User) UpdateUser

func (user User) UpdateUser(accessToken, refreshToken string)

UpdateUser updates an existing user object

Jump to

Keyboard shortcuts

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