rpc

package
v0.31.2-mocha Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CORSConfig added in v0.25.3

type CORSConfig struct {
	Enabled        bool
	AllowedOrigins []string
	AllowedMethods []string
	AllowedHeaders []string
}

type RateLimitConfig

type RateLimitConfig struct {
	// Enabled toggles the per-IP rate limit middleware.
	Enabled bool
	// RequestsPerSec is the sustained per-IP request rate; requests above
	// this rate (after burst is drained) get 429 Too Many Requests.
	RequestsPerSec int
	// Burst is the per-IP burst allowance — the bucket size that absorbs
	// short spikes before sustained rate kicks in.
	Burst int
	// CacheSize is the max number of per-IP buckets retained.
	// When exceeded, the least-recently-seen IP is evicted (and gets a fresh
	// burst on its next request). Bounds memory under unique-IP floods.
	CacheSize int
}

RateLimitConfig configures per-IP rate limiting based on the connection's remote address. When the node runs behind a reverse proxy, RemoteAddr is the proxy's address, so all clients share one bucket — in that case keep this disabled and apply rate limiting at the proxy instead.

type Server

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

func NewServer

func NewServer(
	address, port string,
	authDisabled bool,
	corsConfig CORSConfig,
	tlsConfig TLSConfig,
	rateLimitCfg RateLimitConfig,
	signer jwt.Signer,
	verifier jwt.Verifier,
) *Server

func (*Server) ListenAddr

func (s *Server) ListenAddr() string

ListenAddr returns the listen address of the server.

func (*Server) RegisterService

func (s *Server) RegisterService(namespace string, service, out any)

RegisterService registers a service onto the RPC server. All methods on the service will then be exposed over the RPC.

func (*Server) Start

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

Start starts the RPC Server.

func (*Server) Stop

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

Stop stops the RPC Server.

func (*Server) WithMetrics

func (s *Server) WithMetrics() error

WithMetrics enables OTel metrics on the RPC server. Must be called before Start, since it rebuilds the handler stack to install the metrics middleware and registers an http.Server.ConnState hook for connection-level gauges.

type TLSConfig added in v0.30.2

type TLSConfig struct {
	Enabled  bool
	CertPath string
	KeyPath  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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