proxy

package
v0.0.0-...-e3a76c1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionInfo

type ConnectionInfo struct {
	Source     string
	Target     string
	Ingress    string
	BytesIn    int64
	BytesOut   int64
	DurationMs float64
}

ConnectionInfo captures an observed TCP connection.

type Event

type Event struct {
	Type         string
	Request      *RequestInfo
	Connection   *ConnectionInfo
	GRPCCall     *GRPCCallInfo
	KafkaRequest *KafkaRequestInfo
}

Event is the proxy-internal event type emitted by forwarders. The lifecycle layer converts these into server.Event entries.

type Forwarder

type Forwarder struct {
	ListenAddr string
	Target     spec.Endpoint // real service endpoint to forward to
	Source     string        // source service name or "external"
	TargetSvc  string        // target service name
	Ingress    string        // target ingress name
	Protocol   string        // from spec: "http", "tcp", etc.
	Emit       func(Event)   // publish to event log
	Decoder    *GRPCDecoder  // set once before traffic flows; nil if reflection unavailable
	Listener   net.Listener  // pre-opened listener; avoids TOCTOU race when set
}

Forwarder observes traffic for a single egress edge or external connection. It listens on a single port and forwards to the real service endpoint, emitting events for each request or connection.

func (*Forwarder) Endpoint

func (f *Forwarder) Endpoint() spec.Endpoint

Endpoint returns the proxy endpoint that callers should connect to. Attributes are copied unchanged — they contain templates (e.g. "${HOST}") that resolve correctly against the proxy's HostPort when consumed.

func (*Forwarder) Runner

func (f *Forwarder) Runner() run.Runner

Runner returns a run.Runner that listens and forwards traffic. Dispatches to HTTP reverse proxy or TCP relay based on Protocol.

type GRPCCallInfo

type GRPCCallInfo struct {
	Source           string
	Target           string
	Ingress          string
	Service          string // "pkg.ServiceName"
	Method           string // "MethodName"
	GRPCStatus       string // "0" (OK), "5" (NOT_FOUND), etc.
	GRPCMessage      string // status message
	LatencyMs        float64
	RequestSize      int64
	ResponseSize     int64
	RequestMetadata  map[string][]string
	ResponseMetadata map[string][]string

	RequestBody           []byte
	RequestBodyTruncated  bool
	ResponseBody          []byte
	ResponseBodyTruncated bool
	RequestBodyDecoded    string // JSON from reflection, empty if unavailable
	ResponseBodyDecoded   string
}

GRPCCallInfo captures an observed gRPC call.

type GRPCDecoder

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

GRPCDecoder decodes gRPC request/response bodies into JSON using descriptors obtained via server reflection.

func ProbeReflection

func ProbeReflection(ctx context.Context, addr string) *GRPCDecoder

ProbeReflection dials the target gRPC server and attempts to fetch service descriptors via the v1 reflection API. Returns nil if reflection is not available or any error occurs. The caller should treat nil as "no decoder".

func (*GRPCDecoder) Decode

func (d *GRPCDecoder) Decode(svc, method string, framedData []byte, isRequest bool) string

Decode decodes a gRPC framed body (length-prefixed protobuf) into JSON. svc is "pkg.Service", method is "Method". isRequest selects which descriptor (input or output) to use. Returns "" on any failure.

type KafkaRequestInfo

type KafkaRequestInfo struct {
	Source        string
	Target        string
	Ingress       string
	APIKey        int16
	APIName       string // "Produce", "Fetch", "Metadata", etc.
	APIVersion    int16
	CorrelationID int32
	LatencyMs     float64
	RequestSize   int64
	ResponseSize  int64
}

KafkaRequestInfo captures an observed Kafka request/response pair.

type RequestInfo

type RequestInfo struct {
	Source       string
	Target       string
	Ingress      string
	Method       string
	Path         string
	StatusCode   int
	LatencyMs    float64
	RequestSize  int64
	ResponseSize int64

	RequestHeaders        map[string][]string
	RequestBody           []byte
	RequestBodyTruncated  bool
	ResponseHeaders       map[string][]string
	ResponseBody          []byte
	ResponseBodyTruncated bool
}

RequestInfo captures an observed HTTP request/response pair.

Jump to

Keyboard shortcuts

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