mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-30 02:46:30 +02:00
* add tests/benchmarks for http1/http2 tcp tunnels and http1 websockets testenv: - add new TCP upstream - add websocket functions to HTTP upstream - add https support to mock idp (default on) - add new debug flags -env.bind-address and -env.use-trace-environ to allow changing the default bind address, and enabling otel environment based trace config, respectively * linter pass --------- Co-authored-by: Denis Mishin <dmishin@pomerium.com>
68 lines
2.1 KiB
Go
68 lines
2.1 KiB
Go
package upstreams
|
|
|
|
import (
|
|
oteltrace "go.opentelemetry.io/otel/trace"
|
|
"go.opentelemetry.io/otel/trace/noop"
|
|
)
|
|
|
|
type CommonUpstreamOptions struct {
|
|
displayName string
|
|
clientTracerProviderOverride oteltrace.TracerProvider
|
|
serverTracerProviderOverride oteltrace.TracerProvider
|
|
delayShutdown bool
|
|
}
|
|
|
|
type CommonUpstreamOption interface {
|
|
GRPCUpstreamOption
|
|
HTTPUpstreamOption
|
|
TCPUpstreamOption
|
|
}
|
|
|
|
type commonUpstreamOption func(o *CommonUpstreamOptions)
|
|
|
|
// applyGRPC implements CommonUpstreamOption.
|
|
func (c commonUpstreamOption) applyGRPC(o *GRPCUpstreamOptions) { c(&o.CommonUpstreamOptions) }
|
|
|
|
// applyHTTP implements CommonUpstreamOption.
|
|
func (c commonUpstreamOption) applyHTTP(o *HTTPUpstreamOptions) { c(&o.CommonUpstreamOptions) }
|
|
|
|
// applyTCP implements CommonUpstreamOption.
|
|
func (c commonUpstreamOption) applyTCP(o *TCPUpstreamOptions) { c(&o.CommonUpstreamOptions) }
|
|
|
|
func WithDisplayName(displayName string) CommonUpstreamOption {
|
|
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
|
|
o.displayName = displayName
|
|
})
|
|
}
|
|
|
|
func WithNoClientTracing() CommonUpstreamOption {
|
|
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
|
|
o.clientTracerProviderOverride = noop.NewTracerProvider()
|
|
})
|
|
}
|
|
|
|
func WithNoServerTracing() CommonUpstreamOption {
|
|
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
|
|
o.serverTracerProviderOverride = noop.NewTracerProvider()
|
|
})
|
|
}
|
|
|
|
func WithClientTracerProvider(tp oteltrace.TracerProvider) CommonUpstreamOption {
|
|
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
|
|
o.clientTracerProviderOverride = tp
|
|
})
|
|
}
|
|
|
|
func WithServerTracerProvider(tp oteltrace.TracerProvider) CommonUpstreamOption {
|
|
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
|
|
o.serverTracerProviderOverride = tp
|
|
})
|
|
}
|
|
|
|
// WithDelayedShutdown keeps the server alive until the test environment has
|
|
// fully shut down, instead of stopping it during the shutdown sequence.
|
|
func WithDelayedShutdown() CommonUpstreamOption {
|
|
return commonUpstreamOption(func(o *CommonUpstreamOptions) {
|
|
o.delayShutdown = true
|
|
})
|
|
}
|