Help us shape the future of Go! Take the 2026 Go Developer Survey

server

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Overview

Package server wires the cache, command engine and network listeners (TCP text/RESP, RESP and HTTP) together and manages their lifecycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheResponse

type CacheResponse struct {
	Success bool   `json:"success"`
	Value   any    `json:"value,omitempty"`
	Error   string `json:"error,omitempty"`
	Count   int64  `json:"count,omitempty"`
}

CacheResponse is the JSON envelope of every REST response.

type Server

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

Server is a running BoltCache instance.

func New

func New(cfg *config.Config, log *slog.Logger) (*Server, error)

New validates cfg, builds the cache and restores persisted data.

func (*Server) Engine

func (s *Server) Engine() *command.Engine

Engine returns the command engine (useful for embedding and tests).

func (*Server) Run

func (s *Server) Run() error

Run starts the server and blocks until SIGINT/SIGTERM, then shuts down gracefully.

func (*Server) Shutdown

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

Shutdown stops accepting connections, writes a final snapshot and stops background work.

func (*Server) Start

func (s *Server) Start() error

Start binds all configured listeners. On error, already started listeners are stopped.

Jump to

Keyboard shortcuts

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