server

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// EnvPrefix is the prefix that environment variables use.
	EnvPrefix string = "KVDB"
	// ConfigKeyPort is the configuration key for port.
	ConfigKeyPort string = "port"
	// ConfigKeyDebugEnabled is the configuration key for debug mode.
	ConfigKeyDebugEnabled string = "debug_enabled"
	// ConfigKeyDefaultDatabase is the configuration key for default database.
	ConfigKeyDefaultDatabase string = "default_db"
	// ConfigKeyLogFileEnabled is the configuration key for enabling log file.
	ConfigKeyLogFileEnabled string = "logfile_enabled"

	// DefaultDatabase is the name of the default database.
	DefaultDatabase string = "default"

	// EnvVarPassword is the environment variable for server password.
	EnvVarPassword string = EnvPrefix + "_PASSWORD"
)

Variables

This section is empty.

Functions

func StartServer

func StartServer()

StartServer initializes and starts the server.

Types

type InMemoryCredentialStore added in v0.2.0

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

InMemoryCredentialStore stores server credentials like passwords in memory.

func NewInMemoryCredentialStore added in v0.2.0

func NewInMemoryCredentialStore() *InMemoryCredentialStore

func (*InMemoryCredentialStore) IsCorrectServerPassword added in v0.2.0

func (cs *InMemoryCredentialStore) IsCorrectServerPassword(password []byte) error

IsCorrectServerPassword checks if provided password matches the server password. Returns nil if matches, otherwise an error is returned.

func (*InMemoryCredentialStore) SetServerPassword added in v0.2.0

func (cs *InMemoryCredentialStore) SetServerPassword(password []byte) error

SetServerPassword sets a new password for the server. The password is hashed using bcrypt before storing it in memory. If password is set, clients must authenticate using it. Max password size is 72 bytes.

type Server

func NewServer

func NewServer() *Server

func NewServerWithOptions added in v0.7.1

func NewServerWithOptions(options *ServerOptions) *Server

func (*Server) AuthorizeIncomingRpcCall added in v0.2.0

func (s *Server) AuthorizeIncomingRpcCall(ctx context.Context) error

AuthorizeIncomingRpcCall checks that incoming RPC call provides valid credentials.

func (*Server) CloseLogger added in v0.6.0

func (s *Server) CloseLogger()

CloseLogger closes logger and releases its possible resources.

func (*Server) CreateDatabase

CreateDatabase is the implementation of RPC CreateDatabase.

func (*Server) CreateDefaultDatabase added in v0.3.0

func (s *Server) CreateDefaultDatabase(name string)

CreateDefaultDatabase creates an empty default database.

func (*Server) DbMaxKeysReached added in v0.7.1

func (s *Server) DbMaxKeysReached(db *kvdb.Database) bool

DbMaxKeysReached returns true if a database has reached or exceeded the maximum key limit.

func (*Server) DeleteAllKeys added in v0.5.0

DeleteAllKeys is the implementation of RPC DeleteAllKeys.

func (*Server) DeleteDatabase added in v0.4.0

DeleteDatabase is the implementation of RPC DeleteDatabase.

func (*Server) DeleteHashMapFields added in v0.8.0

DeleteHashMapFields is the implementation of RPC DeleteHashMapFields.

func (*Server) DeleteKey

func (s *Server) DeleteKey(ctx context.Context, req *kvdbserver.DeleteKeyRequest) (res *kvdbserver.DeleteKeyResponse, err error)

DeleteKey is the implementation of RPC DeleteKey.

func (*Server) DisableLogger

func (s *Server) DisableLogger()

DisableLogger disables all log outputs from this server.

func (*Server) EnableDebugLogs added in v0.3.0

func (s *Server) EnableDebugLogs()

EnableDebugLogs enables server debug logs.

func (*Server) EnableLogFile added in v0.6.0

func (s *Server) EnableLogFile()

EnableLogFile enables logger to write logs to the log file.

func (*Server) EnablePasswordProtection added in v0.3.0

func (s *Server) EnablePasswordProtection(password string)

EnablePasswordProtection enables server password protection and sets the password.

func (*Server) GetAllDatabases

GetAllDatabases is the implementation of RPC GetAllDatabases.

func (*Server) GetAllHashMapFieldsAndValues added in v0.9.0

GetAllHashMapFieldsAndValues is the implementation of RPC GetAllHashMapFieldsAndValues.

func (*Server) GetDatabaseInfo

GetDatabaseInfo is the implementation of RPC GetDatabaseInfo.

func (*Server) GetHashMapFieldValue added in v0.7.0

GetHashMapFieldValue is the implementation of RPC GetHashMapFieldValue.

func (*Server) GetKeys added in v0.5.0

func (s *Server) GetKeys(ctx context.Context, req *kvdbserver.GetKeysRequest) (res *kvdbserver.GetKeysResponse, err error)

GetKeys is the implementation of RPC GetKeys.

func (*Server) GetLogs added in v0.6.0

func (s *Server) GetLogs(ctx context.Context, req *kvdbserver.GetLogsRequest) (res *kvdbserver.GetLogsResponse, err error)

GetLogs is the implementation of RPC GetLogs.

func (*Server) GetServerInfo

GetServerInfo is the implementation of RPC GetServerInfo.

func (*Server) GetString

func (s *Server) GetString(ctx context.Context, req *kvdbserver.GetStringRequest) (res *kvdbserver.GetStringResponse, err error)

GetString is the implementation of RPC GetString.

func (*Server) GetTypeOfKey added in v0.8.0

GetTypeOfKey is the implementation of RPC GetTypeOfKey.

func (*Server) SetHashMap added in v0.7.0

SetHashMap is the implementation of RPC SetHashMap.

func (*Server) SetLogFilePath added in v0.6.0

func (s *Server) SetLogFilePath(filePath string)

SetLogFilePath sets the file path to the log file.

func (*Server) SetString

func (s *Server) SetString(ctx context.Context, req *kvdbserver.SetStringRequest) (res *kvdbserver.SetStringResponse, err error)

SetString is the implementation of RPC SetString.

type ServerOptions added in v0.7.1

type ServerOptions struct {
	MaxKeysPerDb uint32
}

ServerOptions contains options that can be passed to the server when creating it.

Jump to

Keyboard shortcuts

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