Documentation
¶
Index ¶
- Constants
- Variables
- type ClientsRepository
- type KVClientsRepository
- func (r *KVClientsRepository) AddClientKey(ctx context.Context, clientId string, key string) error
- func (r *KVClientsRepository) GetAllClients(ctx context.Context) ([]*asit.Client, error)
- func (r *KVClientsRepository) GetClientById(ctx context.Context, id string) (*asit.Client, error)
- func (r *KVClientsRepository) GetClientByKey(ctx context.Context, key string) (*asit.Client, error)
- func (r *KVClientsRepository) GetClientKeys(ctx context.Context, clientId string) (*asit.ClientKeys, error)
- func (r *KVClientsRepository) RemoveClient(ctx context.Context, clientId string) error
- func (r *KVClientsRepository) RemoveClientKey(ctx context.Context, key string) error
- func (r *KVClientsRepository) SetClient(ctx context.Context, client *asit.Client) error
- type NonUniqueClientKeyError
- type NotFoundClientByIdError
- type ProtoCodec
- type RedisStorage
- func (s *RedisStorage) Close() error
- func (s *RedisStorage) Delete(ctx context.Context, k ...string) error
- func (s *RedisStorage) Get(ctx context.Context, k string, v proto.Message) (found bool, err error)
- func (s *RedisStorage) Set(ctx context.Context, k string, v proto.Message) error
- func (s *RedisStorage) SetAndDeleteAtomically(ctx context.Context, lockedSets []SetValueCommand, lockedDeleteKeys []string, ...) error
- type SetValueCommand
- type SetValueUnlockedCommand
- type Storage
- type StorageCodec
Constants ¶
View Source
const ( KEY_ALL_CLIENTS = "all_clients" KEY_CLIENT_PREFIX = "client:" KEY_CLIENT_KEY_PREFIX = "client_key:" KEY_CLIENT_KEYS_PREFIX = "client_keys:" )
Variables ¶
View Source
var PROTO_CODEC = ProtoCodec{}
Functions ¶
This section is empty.
Types ¶
type ClientsRepository ¶
type ClientsRepository interface {
GetAllClients(ctx context.Context) ([]*asit.Client, error)
GetClientById(ctx context.Context, id string) (*asit.Client, error)
SetClient(ctx context.Context, client *asit.Client) error
RemoveClient(ctx context.Context, clientId string) error
GetClientKeys(ctx context.Context, clientId string) (*asit.ClientKeys, error)
AddClientKey(ctx context.Context, clientId string, key string) error
GetClientByKey(ctx context.Context, key string) (*asit.Client, error)
RemoveClientKey(ctx context.Context, key string) error
}
type KVClientsRepository ¶
type KVClientsRepository struct {
// contains filtered or unexported fields
}
func NewKVClientsRepository ¶
func NewKVClientsRepository(store Storage) *KVClientsRepository
func (*KVClientsRepository) AddClientKey ¶
func (*KVClientsRepository) GetAllClients ¶
func (*KVClientsRepository) GetClientById ¶
func (*KVClientsRepository) GetClientByKey ¶
func (*KVClientsRepository) GetClientKeys ¶
func (r *KVClientsRepository) GetClientKeys(ctx context.Context, clientId string) (*asit.ClientKeys, error)
func (*KVClientsRepository) RemoveClient ¶
func (r *KVClientsRepository) RemoveClient(ctx context.Context, clientId string) error
func (*KVClientsRepository) RemoveClientKey ¶
func (r *KVClientsRepository) RemoveClientKey(ctx context.Context, key string) error
type NonUniqueClientKeyError ¶
type NonUniqueClientKeyError struct {
// contains filtered or unexported fields
}
func (*NonUniqueClientKeyError) Error ¶
func (e *NonUniqueClientKeyError) Error() string
type NotFoundClientByIdError ¶
type NotFoundClientByIdError struct {
// contains filtered or unexported fields
}
func (*NotFoundClientByIdError) Error ¶
func (e *NotFoundClientByIdError) Error() string
type ProtoCodec ¶
type ProtoCodec struct{}
type RedisStorage ¶
type RedisStorage struct {
// contains filtered or unexported fields
}
func NewRedisStorage ¶
func NewRedisStorage(client redis.UniversalClient, codec StorageCodec) *RedisStorage
func (*RedisStorage) Close ¶
func (s *RedisStorage) Close() error
func (*RedisStorage) SetAndDeleteAtomically ¶
func (s *RedisStorage) SetAndDeleteAtomically(ctx context.Context, lockedSets []SetValueCommand, lockedDeleteKeys []string, unlockedSets func() []SetValueUnlockedCommand, unlockedDeleteKeys func() []string) error
type SetValueCommand ¶
type SetValueCommand struct {
// contains filtered or unexported fields
}
Storage is an abstraction for different key-value store implementations. A store must be able to store, retrieve and delete key-value pairs, with the key being a string and the value being any Go interface{}.
type SetValueUnlockedCommand ¶
type SetValueUnlockedCommand struct {
// contains filtered or unexported fields
}
type Storage ¶
type Storage interface {
// Set stores the given value for the given key.
// The implementation automatically marshalls the value.
// The marshalling format depends on the implementation. It can be JSON, gob etc.
// The key must not be "" and the value must not be nil.
Set(ctx context.Context, k string, v proto.Message) error
// Updates multiple values specified by SetValueCommand, deleteKeys and afterRemovalKeysSupplier atomically
// Deletes keys sepcified in deleteKeys
// If keys used lockedSets and lockedDeleteKeys not changed during update, rocesses all commands provided by the unlockedSets func
// Not that unlockedSets will be processed even if values with the same keys changed/set/removed during the lockedSets, lockedDeleteKeys processing
SetAndDeleteAtomically(ctx context.Context, lockedSets []SetValueCommand, lockedDeleteKeys []string, unlockedSets func() []SetValueUnlockedCommand, unlockedDeleteKeys func() []string) error
// Get retrieves the value for the given key.
// The implementation automatically unmarshalls the value.
// The unmarshalling source depends on the implementation. It can be JSON, gob etc.
// The automatic unmarshalling requires a pointer to an object of the correct type
// being passed as parameter.
// In case of a struct the Get method will populate the fields of the object
// that the passed pointer points to with the values of the retrieved object's values.
// If no value is found it returns (false, nil).
// The key must not be "" and the pointer must not be nil.
Get(ctx context.Context, k string, v proto.Message) (found bool, err error)
// Delete deletes the stored value for the given key.
// Deleting a non-existing key-value pair does NOT lead to an error.
// The key must not be "".
Delete(ctx context.Context, k ...string) error
// Close must be called when the work with the key-value store is done.
// Most (if not all) implementations are meant to be used long-lived,
// so only call Close() at the very end.
// Depending on the store implementation it might do one or more of the following:
// Make sure all pending updates make their way to disk,
// finish open transactions,
// close the file handle to an embedded DB,
// close the connection to the DB server,
// release any open resources,
// etc.
// Some implementUniversalation might not need the store to be closed,
// but as long as you work with the gokv.Store interface you never know which implementation
// is passed to your method, so you should always call it.
Close() error
}
Click to show internal directories.
Click to hide internal directories.