rpc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartRPCServer

func StartRPCServer(store *db.ShardedInMemoryStore, port string, logger *logger.Logger)

StartRPCServer starts the RPC server.

Types

type RPCRequest

type RPCRequest struct {
	Key   string `json:"key"`
	Value string `json:"value,omitempty"`
	TTL   int64  `json:"ttl"` // TTL in seconds
}

RPCRequest represents the structure of an RPC request.

type RPCResponse

type RPCResponse struct {
	Success bool   `json:"success"`
	Data    string `json:"data,omitempty"`
	Error   string `json:"error,omitempty"`
}

RPCResponse represents the structure of an RPC response.

type RPCService

type RPCService struct {
	Store  *db.ShardedInMemoryStore
	Logger *logger.Logger
}

RPCService provides the RPC methods for the InMemoryStore.

func (*RPCService) RPCDelete

func (s *RPCService) RPCDelete(req *RPCRequest, resp *RPCResponse) error

RPCDelete removes a key-value pair from the store.

func (*RPCService) RPCGet

func (s *RPCService) RPCGet(req *RPCRequest, resp *RPCResponse) error

RPCGet retrieves a value by key from the store.

func (*RPCService) RPCSet

func (s *RPCService) RPCSet(req *RPCRequest, resp *RPCResponse) error

RPCSet sets a key-value pair in the store.

Jump to

Keyboard shortcuts

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