dataplane

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package dataplane assembles the proxy's request path: one inbound gateway that routes by namespace, and one proxy per upstream that translates namespaces, attaches outbound credentials, and optionally encrypts payloads before forwarding to a Temporal Service.

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(newFromParams),
	fx.Invoke(func(lc fx.Lifecycle, d *Dataplane) {
		lc.Append(fx.Hook{OnStart: d.Start, OnStop: d.Stop})
	}),
)

Module provides a Dataplane from the assembled application and binds Start and Stop to the fx lifecycle. It replaces the router, proxy, and server modules: this is the only place in the graph that owns the gateway/proxy topology.

Functions

This section is empty.

Types

type Dataplane

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

Dataplane is the assembled request path. It is single-use: not restartable after Stop.

func New

func New(ctx context.Context, cfg *config.Config, opts ...Option) (*Dataplane, error)

New validates cfg in full, compiles the routing table, derives each upstream's socket path once, and builds both tiers. ctx is long lived and drives each tier's health check; the context passed to Start bounds startup only. Neither stops serving, which only Stop does. New binds nothing and dials nothing. Every Prometheus collector is registered here, so New must be called once per registry.

func (*Dataplane) Addr

func (d *Dataplane) Addr() net.Addr

Addr is the address the gateway is accepting on, nil before Start.

func (*Dataplane) SocketPath

func (d *Dataplane) SocketPath(upstream string) (string, error)

SocketPath is the unix path the named upstream's proxy binds and the gateway dials. It is the single derivation of that path.

func (*Dataplane) Start

func (d *Dataplane) Start(ctx context.Context) error

Start binds and serves every upstream socket, opens every static upstream connection so an unreachable one fails startup, then binds and serves the gateway, in that order. It returns once the gateway is accepting. ctx bounds startup only and should carry a deadline, since it is what limits the wait for an upstream to answer; the serving goroutines get the Context passed to New instead. A failure part-way through stops whatever already started.

func (*Dataplane) Stop

func (d *Dataplane) Stop(ctx context.Context) error

Stop drains the gateway first, so no request is admitted for a tier that is going away, then every upstream proxy. Each tier's drain is bounded, so the upstreams go concurrently: they are independent, and serially their budgets would sum, which is how a shutdown overruns the lifecycle deadline and strands the hooks queued behind this one.

type Option

type Option func(*options)

Option configures a Dataplane via New.

func WithAbort

func WithAbort(fn func(error)) Option

WithAbort sets a function called at most once, from the goroutine that was serving, when a tier stops for a reason other than Stop. It must not block and must not call back into the Dataplane.

func WithAllowlist

func WithAllowlist(a services.Allowlist) Option

WithAllowlist sets the allowlist that decides which services may be forwarded. Required.

func WithAuth

func WithAuth(a auth.Authenticator) Option

WithAuth sets the authenticator applied to inbound gateway requests. Required.

func WithExtractor

func WithExtractor(e *protoutil.Extractor) Option

WithExtractor sets the extractor the gateway reads routing fields with. Required.

func WithLogger

func WithLogger(log logger.Logger) Option

WithLogger sets the logger used by the dataplane and both tiers, defaulting to logger.Default. A nil logger keeps the default, so an absent optional dependency can be passed straight through.

func WithMetrics

func WithMetrics(f *metrics.Factory) Option

WithMetrics sets the factory every collector is registered with. Required.

func WithPool

func WithPool(p *connect.Pool) Option

WithPool sets the connection pool the dataplane creates upstream connections from. The pool's lifecycle stays with the caller. Required.

func WithProtoTypes

func WithProtoTypes(t protoutil.Types) Option

WithProtoTypes sets the type registry messages are resolved against, defaulting to protoregistry.GlobalTypes. A nil registry keeps the default, so an absent optional dependency can be passed straight through.

func WithTranslator

func WithTranslator(t *protoutil.Translator) Option

WithTranslator sets the translator each upstream rewrites namespaces with. Required.

func WithVault

func WithVault(v *crypto.Vault) Option

WithVault sets the vault used to seal and open payloads. Omit it when no encryption keys are configured; New rejects enabled encryption without one.

type Params

type Params struct {
	fx.In
	Shutdowner fx.Shutdowner

	Context    context.Context
	Config     *config.Config
	Extractor  *protoutil.Extractor
	Translator *protoutil.Translator
	Pool       *connect.Pool
	Metrics    *metrics.Factory
	Allowlist  services.Allowlist
	Auth       auth.Authenticator
	Vault      *crypto.Vault

	Types  protoutil.Types `optional:"true"`
	Logger logger.Logger   `optional:"true"`
}

Params collects the fx-provided dependencies New needs. Types and Logger are optional: New falls back to the global proto registry and the default logger when neither is supplied.

Directories

Path Synopsis
Package dataplanetest runs a dataplane for a test, either constructed directly or assembled from the production fx modules, together with the fake upstreams and connections needed to drive it.
Package dataplanetest runs a dataplane for a test, either constructed directly or assembled from the production fx modules, together with the fake upstreams and connections needed to drive it.

Jump to

Keyboard shortcuts

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