server

package
v0.83.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: BSD-3-Clause Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Handler         http.Handler
	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 gRPC handler proxying.

func New

func New(handler http.Handler, 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