rpcserver

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host string `koanf:"host" default:"localhost"`
	Port uint16 `koanf:"port" default:"5000"`
}

Config contains the configuration for creating a Server instance.

type Handler

type Handler interface {
	Register(*http.ServeMux, []connect.HandlerOption)
}

Handler implementations can register themselves to be hosted by the server.

type Recoverer

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

Recoverer handles the recovery from panics and should be used with connect.WithRecover.

When a panic occurs, the following are performed:

- A log record is produced containing the panic value and stacktrace. - If available, the current span's status is set to error and the panic value is recorded as an event. - The "rpc.server.panics" counter metric is incremented. This metric includes the "rpc.service" and "rpc.method" attributes.

func NewRecoverer

func NewRecoverer() (*Recoverer, error)

...

func (*Recoverer) Handle

func (r *Recoverer) Handle(ctx context.Context, spec connect.Spec, _ http.Header, recovered any) error

...

type Server

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

Server provides a HTTP/2 server for one or more HTTP handlers.

func New

func New(host string, port uint16, handlers []Handler, opts []connect.HandlerOption) *Server

New creates a new Server instance.

func NewFromConfig

func NewFromConfig(config Config, handlers []Handler, opts []connect.HandlerOption) *Server

New creates a new Server instance from the given configuration.

func (*Server) Shutdown

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

Shutdown gracefully stops the server.

func (*Server) Start

func (s *Server) Start() error

Start starts the server. This blocks until the server stops.

Directories

Path Synopsis
interceptors
validatex
...
...

Jump to

Keyboard shortcuts

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