temporal-proxy

module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT

README

Temporal Proxy (Pre-release)

ci codecov release Docs Go Reference license

A gRPC proxy that sits between Temporal SDK Clients, Workers, and the Temporal UI on one side and one or more upstream Temporal Services on the other. It handles Namespace translation, TLS termination, and payload encryption so applications can target a single local endpoint while the proxy fans requests out to the right upstream (a local dev Temporal Service, a self-hosted deployment, Temporal Cloud, or some mix).

[!NOTE]

Pre-release: This project is under active development and evolving quickly. It is not ready for production use. Open a GitHub issue if you have questions or want to follow along.

Why

Connection details leak into application code. Every Worker and Client has to know the upstream's host, TLS material, credentials, and the exact Namespace name the upstream expects. That couples your code to an environment and makes moving between a local Temporal Service, a self-hosted deployment, and Temporal Cloud a code change.

The proxy pulls that concern out. Workers talk plaintext to a single local endpoint using a short Namespace name; the proxy owns TLS, credentials, and Namespace translation on the way out. Point a Worker at a different Namespace and it reaches a different upstream with no change to the Worker.

How

  flowchart LR
    Worker[Worker]
    Client[SDK Client]
    UI[Web UI]

    subgraph Proxy[Temporal Proxy]
        direction LR
        Gateway["Gateway<br/>routes by Namespace<br/>codec-transparent (no payload parsing)"]
        ProxyA["Per-upstream proxy A<br/>Namespace translation<br/>payload encryption (optional)"]
        ProxyB["Per-upstream proxy B<br/>Namespace translation<br/>payload encryption (optional)"]
        Gateway -->|unix socket| ProxyA
        Gateway -->|unix socket| ProxyB
    end

    Cloud[Temporal Cloud]
    SelfHosted[Self-hosted Temporal Service]

    Worker --> Gateway
    Client --> Gateway
    UI --> Gateway
    ProxyA --> Cloud
    ProxyB --> SelfHosted

Features

  • Rule-based routing. Route requests to different upstreams by Namespace and/or request metadata, with a system upstream for Namespace-less calls and a default fallback.
  • Service allowlist. Forward only the gRPC services you name, defaulting to WorkflowService and OperatorService. Server reflection is opt-in, and a service you leave out is never forwarded.
  • Namespace translation. Rewrite local Namespace names to the names an upstream expects (prefix, suffix, or explicit overrides) in both requests and responses.
  • TLS termination and outbound credentials. Terminate inbound TLS/mTLS and attach the upstream's own TLS and credentials (API key or mTLS), so client code carries none of it.
  • Payload encryption. Optionally seal payloads with envelope encryption on the hop to an upstream and open them on responses, so the upstream only ever sees ciphertext while local Workers keep exchanging cleartext. DEKs are wrapped by a KMS key (AWS KMS, Azure Key Vault, or GCP KMS), rotate automatically, and can be overridden per Namespace.
  • Pluggable key management. For a backend the proxy has no built-in support for, such as an on-prem HSM or an internal key service, point it at an extension server you run and it wraps DEKs through that instead. Only key material is exchanged; payloads never reach it.
  • Inbound authentication and authorization. Optional static-token or JWKS validation on the gateway; off by default. For rules neither covers, delegate the decision to an extension server you run. It is told what the call is addressing (the gRPC method, and the Namespace the proxy resolved from the request rather than from anything the caller claims), so it can decide per Namespace and per method rather than only whether the caller is who it says it is.
  • Prometheus metrics. Expose request latency and counts, routing decisions, and payload sealing and opening on /metrics. The listen address and the metric prefix stamped onto every metric name are set under metrics: in the config, along with the labels every series carries: constants such as the region the proxy runs in, and request metadata carried onto the request-scoped series, so they can be sliced by a dimension only your callers know.
  • Codec-transparent. The gateway never parses payloads. It peeks the Namespace, picks an upstream, and relays raw frames in both directions.
  • Multiple deployment options. Ship as a Go binary, a container image, or a Helm chart.

Installation

Go

Install the proxy binary into your $GOBIN with go install:

go install github.com/temporalio/temporal-proxy/cmd/proxy@latest

@latest resolves to the newest stable release. Pin an explicit version from the releases page if you prefer:

go install github.com/temporalio/temporal-proxy/cmd/proxy@vX.Y.Z
Container image

Images are published to Docker Hub:

docker pull temporalio/temporal-proxy:latest
Helm

A chart is published to the Temporal Helm repo at https://go.temporal.io/helm-charts:

# Latest stable release
helm install temporal-proxy temporal-proxy \
  --repo https://go.temporal.io/helm-charts

# Or pin a specific proxy version (see the releases page)
helm install temporal-proxy temporal-proxy \
  --repo https://go.temporal.io/helm-charts \
  --set image.tag=vX.Y.Z

Each chart release deploys a proxy version by default; --set image.tag overrides it to pin a specific one.

Supply the proxy config under the config: key in a values file and pass it with -f:

# values.yaml
config:
  hostPort: :7233
  upstreams:
    - name: local
      hostPort: localhost:7234
      insecure: true
  routing:
    default: local
helm install temporal-proxy temporal-proxy \
  --repo https://go.temporal.io/helm-charts \
  -f values.yaml

See the chart README for the full set of options.

Get started

The Temporal Cloud example is the quickest way to see the proxy in action: a Worker and starter that carry no Cloud configuration talk plaintext to localhost:7233, and the proxy adds TLS, the API key, and the Namespace rewrite on the way to Cloud. Follow its README to run it end to end.

The KMS extension server example shows the pluggable key management path end to end: a local dev server, a key provider you run, and Workflow payloads that the Temporal Service only ever stores as ciphertext. It is built on pkg/ext, which supplies the gRPC surface, the credential check, TLS, and graceful shutdown, so writing your own extension server means implementing the key handling and little else.

The authorization example does the same for access control: an extension server maps a JWT to claims and then decides each call against them, the two steps Temporal OSS splits across its ClaimMapper and Authorizer. Four tokens show what that buys, including a Worker that cannot reach a second Namespace and an auditor that can read history but not start a Workflow.

Metrics

The proxy serves Prometheus metrics on /metrics. Everything under metrics: in the config controls the endpoint and how series are labeled:

Key Default Meaning
hostPort :9090 Address the /metrics handler listens on.
namespace tmprl_proxy The metric prefix stamped onto every metric name. Unrelated to a Temporal Namespace.
labels.namespace false Whether series that can name a Temporal Namespace report it.
labels.fixed none Constant labels stamped on every series, written as a name-to-value map.
labels.metadata none Request metadata to report as extra labels, each written <header>:<name>.
Published series

Every name below is prefixed with the metric prefix and its subsystem, so requests_total in the server subsystem is exposed as tmprl_proxy_server_requests_total by default. Each configured metadata label is added to the series emitted while serving a request: the server and router series, and vault_ops. The KEK and DEK series do not carry them, because they are emitted off the request path where no metadata is in scope to read. A fixed label is added to every series in the table, and to nothing registered outside the proxy's own collectors, so the runtime's go_* and process_* series stay as they are.

Subsystem Metric Type Labels
server requests_total counter method, code
server request_duration_seconds histogram method
router decisions_total counter upstream, outcome
router forwarding_errors_total counter upstream, reason
encryption vault_ops_total counter operation, result, namespace
encryption vault_ops_duration_seconds histogram operation, namespace
encryption kek_ops_total counter provider, operation, result
encryption kek_ops_duration_seconds histogram provider, operation
encryption dek_ops_total counter operation, result
encryption dek_ops_duration_seconds histogram operation
encryption dek_rotations_total counter reason
encryption dek_cache_hits_total counter none
encryption dek_cache_misses_total counter none
encryption dek_cache_size gauge none

The encryption subsystem only reports once encryption keys are configured.

Labels and cardinality

namespace is always declared and reports an empty value when it is turned off. Prometheus treats an empty label value as the label not being there, so turning it on leaves the shape of a query that already ignores it unchanged.

namespace is the local Namespace the Client asked for, before any Namespace translation, which is the same name you write under encryption.overrides. Two proxies fronting different Temporal Services can therefore both report a Namespace called default, so a shared Prometheus needs something else to tell those series apart: a labels.fixed entry, or a label from the scrape job.

labels.namespace is off by default because the label is unbounded: the value comes from the request, so every distinct Namespace a Client names becomes another series. Turn it on when you know that set is small. method is bounded the same way, only for trusted callers, which is why the gateway should not be exposed directly to untrusted Clients.

A labels.metadata entry is unbounded for the same reason, and it multiplies every request-scoped series rather than adding to them, so name a header whose values you know. Two things to know before naming one: /metrics is served unauthenticated, so a header carrying a credential publishes it, and a name that collides with a label a series already declares fails at startup with a message naming the collision.

A labels.fixed entry costs no cardinality, since its value never varies, which is what makes it the right place for a per-installation fact like a region, a zone, or a cluster name. It is also the only shape that reaches the KEK and DEK series. The same collision rule applies, and one more: a name a labels.metadata entry already reports under is refused, because Prometheus rejects a collector whose constant labels clash with its variable ones.

Stability

These names and labels are a published contract, pinned by a test that fails on any change to them. Renames ship with a release note.

Terms

Term Meaning
gateway The single inbound gRPC endpoint that every SDK Client, Worker, and the UI connects to. It routes each request to an upstream by Namespace and/or request metadata, and never parses payloads.
upstream A configured destination the proxy forwards to: a Temporal Service (local dev, self-hosted, or Temporal Cloud), or another Temporal Proxy.
system upstream The upstream that handles Namespace-less requests, such as the SDK's GetSystemInfo call on connect.
extension server A gRPC service you run that the proxy calls out to for a capability it has no built-in backend for: wrapping DEKs, or deciding if a call may proceed. Build one with pkg/ext.
Temporal Service A Temporal deployment the proxy connects to: a local dev server, a self-hosted deployment, or Temporal Cloud.

Development

See .github/CONTRIBUTING.md for the dev loop. The common entry points are mise run test, mise run lint, and mise run format.

Security

See SECURITY.md for how to report vulnerabilities.

License

MIT, see LICENSE.

Directories

Path Synopsis
cmd
proxy command
Package e2e contains black-box, full-stack integration tests that drive the proxy the way production does: a client through the gateway, router, per-upstream proxy, and out to a fake upstream.
Package e2e contains black-box, full-stack integration tests that drive the proxy the way production does: a client through the gateway, router, per-upstream proxy, and out to a fake upstream.
internal
api
Package api reaches the extension servers an operator runs: gRPC services implementing one of the contracts published under api/, currently api.kms.v1.EncryptionService and api.auth.v1.AuthService.
Package api reaches the extension servers an operator runs: gRPC services implementing one of the contracts published under api/, currently api.kms.v1.EncryptionService and api.auth.v1.AuthService.
auth
Package auth authenticates requests arriving at the proxy.
Package auth authenticates requests arriving at the proxy.
auth/outbound
Package outbound presents the proxy's own credentials on connections it dials.
Package outbound presents the proxy's own credentials on connections it dials.
cloud
Package cloud holds the rules that are specific to Temporal Cloud rather than to any Temporal Service.
Package cloud holds the rules that are specific to Temporal Cloud rather than to any Temporal Service.
cloud/translation
Package translation rewrites one gRPC method call into another on the hop to the upstream.
Package translation rewrites one gRPC method call into another on the hop to the upstream.
config
Package config loads and validates the proxy YAML configuration.
Package config loads and validates the proxy YAML configuration.
dataplane
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.
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.
dataplane/dataplanetest
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.
kms
Package kms wires the proxy's encryption configuration into a running crypto.Vault.
Package kms wires the proxy's encryption configuration into a running crypto.Vault.
metrics
Package metrics wires Prometheus metrics into the proxy.
Package metrics wires Prometheus metrics into the proxy.
protoutil
Package protoutil provides helpers for working with Temporal's protobuf request types at the gRPC boundary, without the caller needing to know the concrete message type for a given method.
Package protoutil provides helpers for working with Temporal's protobuf request types at the gRPC boundary, without the caller needing to know the concrete message type for a given method.
proxy
Package proxy serves every allowlisted service on a local unix socket, forwarding each request to an upstream Temporal Service over gRPC.
Package proxy serves every allowlisted service on a local unix socket, forwarding each request to an upstream Temporal Service over gRPC.
router
Package router transparently forwards inbound gRPC traffic to an upstream connection without decoding it.
Package router transparently forwards inbound gRPC traffic to an upstream connection without decoding it.
rpc
Package rpc holds the gRPC stream plumbing the proxy's forwarding paths share.
Package rpc holds the gRPC stream plumbing the proxy's forwarding paths share.
services
Package services names the gRPC services the proxy can forward and resolves their descriptors.
Package services names the gRPC services the proxy can forward and resolves their descriptors.
template
Package template renders the templated fields used by the proxy against per-request values.
Package template renders the templated fields used by the proxy against per-request values.
transport/connect
Package connect manages a pool of reusable gRPC client connections keyed by a caller-supplied logical key, distinct from the dial target.
Package connect manages a pool of reusable gRPC client connections keyed by a caller-supplied logical key, distinct from the dial target.
transport/creds
Package creds resolves TLS transport credentials for Temporal proxy connections from a small set of options.
Package creds resolves TLS transport credentials for Temporal proxy connections from a small set of options.
transport/meta
Package meta defines the internal contract for what the gateway learns about a request once and every later stage reads: the Target on the context, and the namespace stamped on outgoing metadata for the per-upstream proxy.
Package meta defines the internal contract for what the gateway learns about a request once and every later stage reads: the Target on the context, and the namespace stamped on outgoing metadata for the per-upstream proxy.
transport/socket
Package socket defines the addressing contract for the proxy's local unix socket.
Package socket defines the addressing contract for the proxy's local unix socket.
version
Package version holds the build identity stamped into the binary at link time.
Package version holds the build identity stamped into the binary at link time.
pkg
codec
Package codec converts Temporal payloads on their way to and from an upstream.
Package codec converts Temporal payloads on their way to and from an upstream.
crypto
Package crypto implements envelope encryption.
Package crypto implements envelope encryption.
ext
Package ext is a starting point for building a temporal-proxy extension server.
Package ext is a starting point for building a temporal-proxy extension server.
logger
Package logger provides a small, leveled, structured logging interface for the proxy along with a zerolog-backed implementation and a no-op implementation for tests.
Package logger provides a small, leveled, structured logging interface for the proxy along with a zerolog-backed implementation and a no-op implementation for tests.
logger/tag
Package tag provides typed key/value pairs used to attach structured context to log entries.
Package tag provides typed key/value pairs used to attach structured context to log entries.
match
Package match implements the simple glob matching used by routing rules to compare namespaces and metadata values.
Package match implements the simple glob matching used by routing rules to compare namespaces and metadata values.
testutil
Package testutil provides helpers and utilities to make testing easier and less tedious.
Package testutil provides helpers and utilities to make testing easier and less tedious.
validation
Package validation provides structured error primitives plus a small rule-based API for accumulating validation failures.
Package validation provides structured error primitives plus a small rule-based API for accumulating validation failures.
validation/certs
Package certs provides reusable validation.Check building blocks for inspecting X.509 certificates and PEM material: expiry, CA basic constraint, signature-algorithm and key-type strength, and key size.
Package certs provides reusable validation.Check building blocks for inspecting X.509 certificates and PEM material: expiry, CA basic constraint, signature-algorithm and key-type strength, and key size.

Jump to

Keyboard shortcuts

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