server

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package server runs the MidnightState gRPC service. It is a native google.golang.org/grpc server (not ConnectRPC) so that clients written against the Acropolis tonic service are byte-for-byte compatible. This package is the server scaffold: it registers a stub MidnightState service whose RPCs all return Unimplemented; the real handlers are added separately.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Logger *slog.Logger
	// Host and Port are the gRPC listen address. Defaults to 0.0.0.0:50051.
	Host string
	Port uint
	// TLSCertFilePath and TLSKeyFilePath enable TLS when both are set. When
	// both are empty the server listens without TLS. Setting only one is an
	// error.
	TLSCertFilePath string
	TLSKeyFilePath  string
	// ShutdownTimeout bounds GracefulStop before escalating to a hard Stop.
	// Defaults to 30s.
	ShutdownTimeout time.Duration
}

Config holds the configuration for the Midnight gRPC server.

type Server

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

Server runs the MidnightState gRPC service over its own listener.

func New

func New(cfg Config) (*Server, error)

New validates cfg and returns a Server. It does not bind or serve; call Start for that.

func (*Server) Start

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

Start binds the listener and serves the gRPC server in a background goroutine. Binding and any TLS keypair load happen synchronously so that address-in-use and certificate errors surface before Start returns. A goroutine watches ctx and performs a bounded graceful shutdown when it is cancelled.

func (*Server) Stop

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

Stop gracefully shuts the server down, bounded by ctx's deadline when set and otherwise by the configured shutdown timeout. It is safe to call repeatedly and concurrently with the context-cancellation path.

Jump to

Keyboard shortcuts

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