server

package
v0.59.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: BSD-3-Clause Imports: 13 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 {
	LocalGRPCAddr   netip.AddrPort
	Path            string
	MetricsRecorder MetricsRecorder
}

Config contains the configuration for the WebSocket proxy.

type MetricsRecorder

type MetricsRecorder interface {
	// RecordConnection records a new connection
	RecordConnection(ctx context.Context)
	// RecordDisconnection records a connection closing
	RecordDisconnection(ctx context.Context)
	// RecordBytesTransferred records bytes transferred in a direction
	RecordBytesTransferred(ctx context.Context, direction string, bytes int64)
	// RecordError records an error
	RecordError(ctx context.Context, errorType string)
}

MetricsRecorder defines the interface for recording proxy metrics

type NoOpMetricsRecorder

type NoOpMetricsRecorder struct{}

NoOpMetricsRecorder is a no-op implementation that does nothing

func (NoOpMetricsRecorder) RecordBytesTransferred

func (n NoOpMetricsRecorder) RecordBytesTransferred(ctx context.Context, direction string, bytes int64)

func (NoOpMetricsRecorder) RecordConnection

func (n NoOpMetricsRecorder) RecordConnection(ctx context.Context)

func (NoOpMetricsRecorder) RecordDisconnection

func (n NoOpMetricsRecorder) RecordDisconnection(ctx context.Context)

func (NoOpMetricsRecorder) RecordError

func (n NoOpMetricsRecorder) RecordError(ctx context.Context, errorType string)

type Option

type Option func(*Config)

Option defines functional options for the Proxy

func WithMetrics

func WithMetrics(recorder MetricsRecorder) Option

WithMetrics sets a custom metrics recorder

func WithOTelMeter

func WithOTelMeter(meter metric.Meter) Option

WithOTelMeter creates and sets an OpenTelemetry metrics recorder

type Proxy

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

Proxy handles WebSocket to TCP proxying for gRPC connections.

func New

func New(localGRPCAddr netip.AddrPort, opts ...Option) *Proxy

New creates a new WebSocket proxy instance with optional configuration

func (*Proxy) Handler

func (p *Proxy) Handler() http.Handler

Handler returns an http.Handler that proxies WebSocket connections to the local gRPC server.

type Recorder

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

Recorder implements MetricsRecorder using OpenTelemetry

func NewMetricsRecorder

func NewMetricsRecorder(meter metric.Meter) (*Recorder, error)

NewMetricsRecorder creates a new OpenTelemetry-based metrics recorder

func (*Recorder) RecordBytesTransferred

func (o *Recorder) RecordBytesTransferred(ctx context.Context, direction string, bytes int64)

func (*Recorder) RecordConnection

func (o *Recorder) RecordConnection(ctx context.Context)

func (*Recorder) RecordDisconnection

func (o *Recorder) RecordDisconnection(ctx context.Context)

func (*Recorder) RecordError

func (o *Recorder) RecordError(ctx context.Context, errorType string)

Jump to

Keyboard shortcuts

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