proxy

package
v0.1.0-alpha.20260716 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package proxy serves the Temporal WorkflowService on a local unix socket, forwarding every request to an upstream Temporal frontend over gRPC. The socket path is derived from the upstream host:port, so local workers connect without TLS while the upstream hop stays secured.

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(fx.Invoke(func(p ProxyParams) error {
	for i := range p.Config.Upstreams {
		upstream := &p.Config.Upstreams[i]

		if err := upstream.Validate(); err != nil {
			return fmt.Errorf("invalid upstream configuration: %w", err)
		}

		if upstream.IsTemplated() {
			return fmt.Errorf(
				"upstream %q has a templated hostPort %q: templated upstreams are not yet supported",
				upstream.Name,
				upstream.Listen.HostPort,
			)
		}

		opts := []Option{WithCredentials(upstreamCreds(upstream))}
		if p.Logger != nil {
			opts = append(opts, WithLogger(p.Logger))
		}

		svr, err := New(upstream.Listen.HostPort, opts...)
		if err != nil {
			return fmt.Errorf("failed to create proxy for upstream %q: %w", upstream.Name, err)
		}

		p.Lifecycle.Append(fx.Hook{
			OnStart: func(context.Context) error {
				go func() {
					if err := svr.Start(p.Context); err != nil {

						_ = p.Shutdowner.Shutdown(fx.ExitCode(1))
					}
				}()

				return nil
			},
			OnStop: svr.Stop,
		})
	}

	return nil
}))

Module is the fx module that constructs the proxy Server from ProxyParams and binds its lifecycle to the application.

Functions

This section is empty.

Types

type Credentials

type Credentials interface {
	DialOption() (grpc.DialOption, error)
}

Credentials produces the grpc.DialOption used to secure the outbound connection to the upstream Temporal frontend.

type Option

type Option func(*Options)

Option configures a Server via New.

func WithCredentials

func WithCredentials(creds Credentials) Option

WithCredentials sets the transport credentials used to dial the upstream frontend.

func WithLogger

func WithLogger(log logger.Logger) Option

WithLogger sets the logger used by the proxy.

type Options

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

Options configures a Server at construction time.

type ProxyParams

type ProxyParams struct {
	fx.In
	Lifecycle  fx.Lifecycle
	Shutdowner fx.Shutdowner

	// Required values
	Context context.Context
	Config  *config.Config

	// Optional values
	Logger logger.Logger `optional:"true"`
}

ProxyParams collects the fx-provided dependencies needed to construct and run the proxy Server. Context and Config are required; Logger is optional and falls back to the default used by New when not supplied.

type Server

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

Server proxies the Temporal WorkflowService. It dials an upstream frontend and re-serves it on a local unix socket, letting local workers connect without TLS while the upstream hop stays secured.

func New

func New(hostPort string, opts ...Option) (*Server, error)

New constructs a Server that forwards WorkflowService traffic to the upstream frontend at hostPort. The local listener is a unix socket whose path is derived from hostPort (see Server.Start). With no options it dials the upstream with insecure credentials and logs via a CLI logger.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start binds the local unix socket and serves until the proxy is stopped or ctx is cancelled. It first removes any socket left behind by a prior run. It blocks, so callers typically run it in its own goroutine.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully shuts the proxy down, waiting for in-flight RPCs to complete.

Jump to

Keyboard shortcuts

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