server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDriver

func RegisterDriver(dbType string, fn Driver)

RegisterDriver registers a driver for a database type. It is intended to be called from a package init() so drivers self-register. Panics on duplicate registration — init() code is expected to catch this early.

Types

type Driver

type Driver func(ctx context.Context, cfg *config.Config) (DriverResources, error)

Driver opens a database connection, constructs its metadata store, and returns the resources needed to serve requests.

type DriverResources

type DriverResources struct {
	Meta    metaStore
	Factory ProviderFactory
	Closer  io.Closer
}

DriverResources holds the resources opened by a Driver. The caller is responsible for calling Closer.Close when done.

type ProviderFactory

type ProviderFactory func(ctx context.Context, name string) (ledgerpb.Provider, error)

ProviderFactory creates a ledgerpb.Provider for a given store name (a table or collection).

type Server

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

Server wraps a gRPC server and its listener.

func New

func New(ctx context.Context, cfg *config.Config) (*Server, error)

New creates and configures the gRPC server from cfg.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the gRPC address the server is listening on.

func (*Server) HTTPAddr added in v0.0.11

func (s *Server) HTTPAddr() string

HTTPAddr returns the HTTP gateway address, or empty string if disabled.

func (*Server) ReloadHooks added in v0.0.10

func (s *Server) ReloadHooks(cfg *config.Config)

ReloadHooks cancels the current hook set, waits for them to stop, then starts a new set from cfg.Hooks. The gRPC listener and backend connection are not affected. No-ops if Stop has already been called.

func (*Server) Serve

func (s *Server) Serve() error

Serve starts both the gRPC server and the HTTP gateway (if configured), and returns the first error from either. Both servers are run in goroutines; callers must call Stop to shut them down.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context)

Stop gracefully drains in-flight RPCs, stops hook runners, then closes the backend resources.

Shutdown order: cancel hooks first so they stop poking the mux, then drain gRPC RPCs, then close the mux and backend connection.

Jump to

Keyboard shortcuts

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