Documentation
¶
Index ¶
- func StartGRPCServer(enableLogging bool, enableSecurity bool) error
- type GRPCServer
- func (s *GRPCServer) Delete(_ context.Context, req *proto.DeleteRequest) (*proto.DeleteResponse, error)
- func (s *GRPCServer) DeleteAll(_ context.Context, _ *proto.DeleteAllRequest) (*proto.DeleteAllResponse, error)
- func (s *GRPCServer) Get(_ context.Context, req *proto.GetRequest) (*proto.KeyValue, error)
- func (s *GRPCServer) GetAll(_ context.Context, _ *proto.GetAllRequest) (*proto.GetAllResponse, error)
- func (s *GRPCServer) GetKeys(_ context.Context, _ *proto.GetKeysRequest) (*proto.GetKeysResponse, error)
- func (s *GRPCServer) GetValues(_ context.Context, _ *proto.GetValuesRequest) (*proto.GetValuesResponse, error)
- func (s *GRPCServer) Set(_ context.Context, req *proto.SetRequest) (*proto.SetResponse, error)
- type KeyValue
- type KeyValueStore
- func (kv *KeyValueStore) Delete(key string) ([]byte, bool)
- func (kv *KeyValueStore) DeleteALL() error
- func (kv *KeyValueStore) Get(key string) (json.RawMessage, bool)
- func (kv *KeyValueStore) GetAll() map[string][]byte
- func (kv *KeyValueStore) GetKeys() []string
- func (kv *KeyValueStore) GetValues() []json.RawMessage
- func (kv *KeyValueStore) InitLogging(logFile string, snapshotInterval time.Duration) error
- func (kv *KeyValueStore) LoadLatestSnapshot() error
- func (kv *KeyValueStore) ProcessLogEntries(entries []LogEntry)
- func (kv *KeyValueStore) Set(key string, value json.RawMessage)
- func (kv *KeyValueStore) TakeSnapshot() error
- type LogEntry
- type Logger
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartGRPCServer ¶
StartGRPCServer starts a gRPC server on port 50051. If enableLogging is true, it initializes logging to the specified file with a rotation interval of 1 hour.
Types ¶
type GRPCServer ¶
type GRPCServer struct {
proto.UnimplementedKeyValueServiceServer
// contains filtered or unexported fields
}
func NewGRPCServer ¶
func NewGRPCServer() *GRPCServer
NewGRPCServer creates a new gRPC server with an empty key-value store.
func (*GRPCServer) Delete ¶
func (s *GRPCServer) Delete(_ context.Context, req *proto.DeleteRequest) (*proto.DeleteResponse, error)
Delete deletes an item in the key-value store by key.
func (*GRPCServer) DeleteAll ¶
func (s *GRPCServer) DeleteAll(_ context.Context, _ *proto.DeleteAllRequest) (*proto.DeleteAllResponse, error)
DeleteAll deletes all items in the key-value store.
func (*GRPCServer) Get ¶
func (s *GRPCServer) Get(_ context.Context, req *proto.GetRequest) (*proto.KeyValue, error)
Get returns an item in the key-value store by key.
func (*GRPCServer) GetAll ¶
func (s *GRPCServer) GetAll(_ context.Context, _ *proto.GetAllRequest) (*proto.GetAllResponse, error)
GetAll returns all items in the key-value store.
func (*GRPCServer) GetKeys ¶
func (s *GRPCServer) GetKeys(_ context.Context, _ *proto.GetKeysRequest) (*proto.GetKeysResponse, error)
GetKeys returns all keys in the key-value store.
func (*GRPCServer) GetValues ¶
func (s *GRPCServer) GetValues(_ context.Context, _ *proto.GetValuesRequest) (*proto.GetValuesResponse, error)
GetValues returns all values in the key-value store.
func (*GRPCServer) Set ¶
func (s *GRPCServer) Set(_ context.Context, req *proto.SetRequest) (*proto.SetResponse, error)
Set sets an item in the key-value store by key and value.
type KeyValue ¶
type KeyValue struct {
Key string `json:"key"`
Value json.RawMessage `json:"value"`
}
func NewKeyValue ¶
func NewKeyValue(key string, value json.RawMessage) *KeyValue
type KeyValueStore ¶
type KeyValueStore struct {
// contains filtered or unexported fields
}
KeyValueStore represents the key-value store.
func NewKeyValueStore ¶
func NewKeyValueStore() *KeyValueStore
NewKeyValueStore creates a new instance of KeyValueStore.
func (*KeyValueStore) Delete ¶
func (kv *KeyValueStore) Delete(key string) ([]byte, bool)
Deletes a specific key value pair from the store.
func (*KeyValueStore) DeleteALL ¶
func (kv *KeyValueStore) DeleteALL() error
Deletes all key/value pairs from the store and clears the transaction logs.
func (*KeyValueStore) Get ¶
func (kv *KeyValueStore) Get(key string) (json.RawMessage, bool)
Get retrieves the value associated with a key from the store.
func (*KeyValueStore) GetAll ¶
func (kv *KeyValueStore) GetAll() map[string][]byte
GetAll retries all key-values pairs from the store.
func (*KeyValueStore) GetKeys ¶
func (kv *KeyValueStore) GetKeys() []string
GetKeys returns all keys from the store.
func (*KeyValueStore) GetValues ¶
func (kv *KeyValueStore) GetValues() []json.RawMessage
GetValues returns all values from the store.
func (*KeyValueStore) InitLogging ¶
func (kv *KeyValueStore) InitLogging(logFile string, snapshotInterval time.Duration) error
func (*KeyValueStore) LoadLatestSnapshot ¶
func (kv *KeyValueStore) LoadLatestSnapshot() error
func (*KeyValueStore) ProcessLogEntries ¶
func (kv *KeyValueStore) ProcessLogEntries(entries []LogEntry)
ProcessLogEntries processes a list of log entries and updates the key-value store accordingly.
func (*KeyValueStore) Set ¶
func (kv *KeyValueStore) Set(key string, value json.RawMessage)
Set adds or updates a key-value pair in the store.
func (*KeyValueStore) TakeSnapshot ¶
func (kv *KeyValueStore) TakeSnapshot() error
type LogEntry ¶
type LogEntry struct {
Timestamp time.Time `json:"timestamp"`
Operation string `json:"operation"`
Key string `json:"key"`
Value string `json:"value"`
}
LogEntry represents a log entry.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a simple logger that writes to a file.