Documentation ¶
Index ¶
- Constants
- Variables
- func InterfaceIsString(a any) (bool, string)
- func IsValidFile(loc string, log *zerolog.Logger) error
- func Redact(s string) string
- type File
- func (f *File) Close(ctx context.Context) error
- func (f *File) Connect(ctx context.Context) (bool, error)
- func (f *File) Delete(ctx context.Context, id string) (bool, error)
- func (f *File) Flush(ctx context.Context) (bool, error)
- func (f *File) Loop()
- func (f *File) Patch(ctx context.Context, id string, token any) (bool, error)
- func (f *File) Retrieve(ctx context.Context, id string) (string, error)
- func (f *File) RetrieveAll(ctx context.Context) (map[string]string, error)
- func (f *File) Store(ctx context.Context, id string, token any) error
- func (f *File) Write(m map[string]string) error
- type FileChannels
- type Gob
- func (g *Gob) Close(ctx context.Context) error
- func (g *Gob) Connect(ctx context.Context) (bool, error)
- func (g *Gob) Delete(ctx context.Context, id string) (bool, error)
- func (g *Gob) Flush(ctx context.Context) (bool, error)
- func (g *Gob) MapDump(ctx context.Context) error
- func (g *Gob) MapRefresh(ctx context.Context) error
- func (g *Gob) Patch(ctx context.Context, id string, token any) (bool, error)
- func (g *Gob) Retrieve(ctx context.Context, id string) (string, error)
- func (g *Gob) RetrieveAll(ctx context.Context) (map[string]string, error)
- func (g *Gob) Store(ctx context.Context, id string, token any) error
- type Map
- func (m *Map) Close(ctx context.Context) error
- func (m *Map) Connect(ctx context.Context) (bool, error)
- func (m *Map) Delete(ctx context.Context, id string) (bool, error)
- func (m *Map) Flush(ctx context.Context) (bool, error)
- func (m *Map) IsExist(key string) bool
- func (m *Map) Map() *sync.Map
- func (m *Map) Patch(ctx context.Context, id string, token any) (bool, error)
- func (m *Map) Retrieve(ctx context.Context, id string) (string, error)
- func (m *Map) RetrieveAll(ctx context.Context) (map[string]string, error)
- func (m *Map) Store(ctx context.Context, id string, token any) error
- type Options
- type Redis
- func (r *Redis) Client() *redis.Client
- func (r *Redis) Close(ctx context.Context) error
- func (r *Redis) Connect(ctx context.Context) (bool, error)
- func (r *Redis) Delete(ctx context.Context, id string) (bool, error)
- func (r *Redis) Flush(ctx context.Context) (bool, error)
- func (r *Redis) IsExists(ctx context.Context, key string) bool
- func (r *Redis) Patch(ctx context.Context, id string, token any) (bool, error)
- func (r *Redis) Ping(ctx context.Context) (bool, error)
- func (r *Redis) Retrieve(ctx context.Context, id string) (string, error)
- func (r *Redis) RetrieveAll(ctx context.Context) (map[string]string, error)
- func (r *Redis) Store(ctx context.Context, id string, token any) (err error)
- type Store
Constants ¶
const ( RedisStatusOkay = "OK" DefaultRedisConnectionString = "redis://localhost:6379" DefaultTTL = 0 )
Const
const ( ErrTokenTypeNotString = "token of type string required" DefaultUnredactedLength = 4 // DefaultRedactedLength ensures infomation about the actual length of the encoded token isn't exposed to an unauthenticated client DefaultRedactedLength = 10 DefaultRedactedToken = "*" )
Variables ¶
var ( ErrWithOperation = "operation completed with error: %s\n" OperationSuccessful = "operation successful" )
Functions ¶
func InterfaceIsString ¶
InterfaceIsString checks if an interface underlying type is a string
func IsValidFile ¶
IsValidFile checks if a given file address is valid
Types ¶
type File ¶
func (*File) RetrieveAll ¶
RetrieveAll retrieves all the tokens from the store
type FileChannels ¶
type FileChannels struct {
// contains filtered or unexported fields
}
type Gob ¶
func (*Gob) Flush ¶
Flush empties the internal sync.Map and the persistent gob store // TODO: why? What is the use case for this? TODO: Flush should rather persist the current state of the in-memory map into disk, and then empty the in-memory map. It isn't idiomatic for flush to clear the persistent store too.
func (*Gob) MapRefresh ¶
MapRefresh refreshes the sync.Map in-memory store with the latest updates from the persistent store
func (*Gob) RetrieveAll ¶
RetrieveAll
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
type Options ¶
Options implements funcitonal options for passing in Redis configuration options
func WithConnectionString ¶
WithConnectionString switches the mode of connection to redis to using
type Redis ¶
Redis holds the config options and the state of the redis connection through the lifetime of the connection.
func NewRedis ¶
NewRedis creates a new instance of Redis, for managing CRUD operations to the configured redis client
func (*Redis) Client ¶
func (r *Redis) Client() *redis.Client
Client returns the Redis client to the caller
func (*Redis) RetrieveAll ¶
RetrieveAll retrieves all the key/value pairs currently stored in the database.
type Store ¶
type Store interface { Connect(ctx context.Context) (bool, error) // Store persists the key value pair to the store. It ensures that it doesn't already exist; if it already does, it aborts. Store(ctx context.Context, id string, token any) error Retrieve(ctx context.Context, id string) (string, error) RetrieveAll(ctx context.Context) (map[string]string, error) Delete(ctx context.Context, id string) (bool, error) Patch(ctx context.Context, id string, token any) (bool, error) Flush(ctx context.Context) (bool, error) Close(ctx context.Context) error }