Documentation ¶
Index ¶
- Constants
- type DB
- func (db *DB) ChangeDescription(newDescription string)
- func (db *DB) ChangeName(newName string)
- func (db *DB) CreatedAt() time.Time
- func (db *DB) DeleteAllKeys()
- func (db *DB) DeleteHashMapFields(key string, fields []string) (uint32, bool)
- func (db *DB) DeleteKeys(keys []string) uint32
- func (db *DB) Description() string
- func (db *DB) GetAllKeys() []string
- func (db *DB) GetEstimatedStorageSizeBytes() uint64
- func (db *DB) GetHashMapFieldValues(key string, fields []string) (map[string]*HashMapFieldValueResult, bool)
- func (db *DB) GetHashMapKey(key string) (HashMapKey, bool)
- func (db *DB) GetKeyCount() int
- func (db *DB) GetKeyType(key string) (DBKeyType, bool)
- func (db *DB) GetStringKey(key string) (StringKey, bool)
- func (db *DB) Name() string
- func (db *DB) SetHashMap(key string, fields map[string][]byte) uint32
- func (db *DB) SetString(key string, value []byte)
- func (db *DB) UpdatedAt() time.Time
- type DBConfig
- type DBKey
- type DBKeyType
- type DefaultLogger
- func (l *DefaultLogger) CloseLogFile() error
- func (l *DefaultLogger) Debug(v ...any)
- func (l *DefaultLogger) Debugf(format string, v ...any)
- func (l *DefaultLogger) Disable()
- func (l *DefaultLogger) EnableLogFile(filepath string) error
- func (l *DefaultLogger) Error(v ...any)
- func (l *DefaultLogger) Errorf(format string, v ...any)
- func (l *DefaultLogger) Fatal(v ...any)
- func (l *DefaultLogger) Fatalf(format string, v ...any)
- func (l *DefaultLogger) Info(v ...any)
- func (l *DefaultLogger) Infof(format string, v ...any)
- func (l *DefaultLogger) LogLevel() (LogLevel, string)
- func (l *DefaultLogger) SetLogLevel(level LogLevel)
- func (l *DefaultLogger) Warning(v ...any)
- func (l *DefaultLogger) Warningf(format string, v ...any)
- type HashMapField
- type HashMapFieldValueResult
- type HashMapKey
- type HashMapValue
- type LogLevel
- type Logger
- type StringKey
- type StringValue
Constants ¶
const ( LogLevelDebug LogLevel = 0 LogLevelInfo LogLevel = 1 LogLevelWarning LogLevel = 2 LogLevelError LogLevel = 3 LogLevelFatal LogLevel = 4 LogLevelDebugStr string = "debug" LogLevelInfoStr string = "info" LogLevelWarningStr string = "warning" LogLevelErrorStr string = "error" LogLevelFatalStr string = "fatal" DefaultLogLevel LogLevel = LogLevelInfo DefaultLogLevelStr string = LogLevelInfoStr )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a database used as a namespace for storing key-value pairs.
func (*DB) ChangeDescription ¶
func (*DB) ChangeName ¶
func (*DB) DeleteHashMapFields ¶
DeleteHashMapFields removes the specified fields from a HashMap key value. Returns the number of removed fields. The returned bool is true if the key exists and holds a HashMap.
func (*DB) DeleteKeys ¶
DeleteKeys deletes the specified keys. Returns the number of keys that were deleted.
func (*DB) Description ¶
func (*DB) GetEstimatedStorageSizeBytes ¶
GetEstimatedStorageSizeBytes returns the estimated size of stored data in bytes.
func (*DB) GetHashMapFieldValues ¶
func (db *DB) GetHashMapFieldValues(key string, fields []string) (map[string]*HashMapFieldValueResult, bool)
GetHashMapFieldValues returns a HashMap key value's field values. The returned bool is true if the key exists, or false if the key doesn't exist.
func (*DB) GetHashMapKey ¶
func (db *DB) GetHashMapKey(key string) (HashMapKey, bool)
GetHashMapKey retrieves a HashMap key value. The returned map is empty if the key doesn't exist. The returned bool is true if the key exists and holds a HashMap.
func (*DB) GetKeyCount ¶
GetKeyCount returns the number of keys in the database.
func (*DB) GetKeyType ¶
GetKeyType returns the data type of the key if it exists. The returned bool is true if the key exists and false if it doesn't.
func (*DB) GetStringKey ¶
GetStringKey retrieves a String key value. The returned bool is true if the key exists and holds a String.
func (*DB) SetHashMap ¶
SetHashMap sets the specified fields in a HashMap key value, overwriting previous fields. Creates the key if it doesn't exist. Returns the number of added fields.
type DBConfig ¶
type DBConfig struct { // The maximum number of fields a HashMap key value can hold. MaxHashMapFields uint32 }
DBConfig contains fields to configure a database.
type DefaultLogger ¶
type DefaultLogger struct {
// contains filtered or unexported fields
}
DefaultLogger is a default implementation of the Logger interface. Log output defaults to standard error stream. Debug logs are disabled by default. Call EnableDebug to enable them.
func DisabledLogger ¶
func DisabledLogger() *DefaultLogger
func NewDefaultLogger ¶
func NewDefaultLogger() *DefaultLogger
func (*DefaultLogger) CloseLogFile ¶
func (l *DefaultLogger) CloseLogFile() error
func (*DefaultLogger) Debug ¶
func (l *DefaultLogger) Debug(v ...any)
func (*DefaultLogger) Debugf ¶
func (l *DefaultLogger) Debugf(format string, v ...any)
func (*DefaultLogger) Disable ¶
func (l *DefaultLogger) Disable()
func (*DefaultLogger) EnableLogFile ¶
func (l *DefaultLogger) EnableLogFile(filepath string) error
func (*DefaultLogger) Error ¶
func (l *DefaultLogger) Error(v ...any)
func (*DefaultLogger) Errorf ¶
func (l *DefaultLogger) Errorf(format string, v ...any)
func (*DefaultLogger) Fatal ¶
func (l *DefaultLogger) Fatal(v ...any)
func (*DefaultLogger) Fatalf ¶
func (l *DefaultLogger) Fatalf(format string, v ...any)
func (*DefaultLogger) Info ¶
func (l *DefaultLogger) Info(v ...any)
func (*DefaultLogger) Infof ¶
func (l *DefaultLogger) Infof(format string, v ...any)
func (*DefaultLogger) LogLevel ¶
func (l *DefaultLogger) LogLevel() (LogLevel, string)
func (*DefaultLogger) SetLogLevel ¶
func (l *DefaultLogger) SetLogLevel(level LogLevel)
func (*DefaultLogger) Warning ¶
func (l *DefaultLogger) Warning(v ...any)
func (*DefaultLogger) Warningf ¶
func (l *DefaultLogger) Warningf(format string, v ...any)
type HashMapField ¶
type HashMapField struct {
Value StringValue
}
HashMapField is a HashMap field that holds a String value.
type HashMapFieldValueResult ¶
type HashMapFieldValueResult struct { // Value is the value the field is holding. FieldValue HashMapField // Ok is true if the field exists. Otherwise false. Ok bool }
type HashMapKey ¶
type HashMapKey struct {
Value HashMapValue
}
HashMapKey is a database key that holds a HashMap value.
type HashMapValue ¶
type HashMapValue map[string]HashMapField
HashMapValue represents a HashMap data type value.
type LogLevel ¶
type LogLevel uint8
func GetLogLevelFromStr ¶
GetLogLevelFromStr returns the log level that matches its string equivalent. If invalid log level string is passed, this function returns the default log level. The returned string is the log level's string equivalent in lowercase. The returned bool is true if the passed string is valid log level.
type Logger ¶
type Logger interface { Debug(v ...any) Debugf(format string, v ...any) Info(v ...any) Infof(format string, v ...any) Error(v ...any) Errorf(format string, v ...any) Warning(v ...any) Warningf(format string, v ...any) Fatal(v ...any) Fatalf(format string, v ...any) // SetLogLevel sets the log level. SetLogLevel(level LogLevel) // LogLevel returns the log level and its string equivalent. LogLevel() (LogLevel, string) // EnableLogFile enables log file. EnableLogFile(filePath string) error // CloseLogFile closes the log file if it is open. CloseLogFile() error // Disable disables all log outputs. Disable() }
type StringKey ¶
type StringKey struct {
Value StringValue
}
StringKey is a database key that holds a String value.