clientpool

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfigError added in v1.13.0

type AuthConfigError struct{ Err error }

func (*AuthConfigError) Error added in v1.13.0

func (e *AuthConfigError) Error() string

func (*AuthConfigError) Unwrap added in v1.13.0

func (e *AuthConfigError) Unwrap() error

type CachedClient added in v1.13.0

type CachedClient struct {
	Client  sdkclient.Client
	IsValid func() bool
}

CachedClient is a Temporal SDK client paired with a validity check. The pool calls IsValid on every cache hit; a false result triggers eviction and re-dial. It is not called at creation time — creation success is the error return of CreateClientFunc.

type ClientPool

type ClientPool struct {

	// CustomizeClientOptions mutates SDK options before dialing. Consumed by
	// DefaultCreateClient; a wrapper using a custom CreateClientFn owns
	// construction entirely and does not use this hook.
	CustomizeClientOptions func(sdkclient.Options) sdkclient.Options

	// CreateClientFn creates and health-checks a client. Defaults to
	// DefaultCreateClient; a wrapper overrides it to own construction.
	CreateClientFn CreateClientFunc
	// contains filtered or unexported fields
}

func New

func New(l log.Logger, c runtimeclient.Client, customizeOptions func(sdkclient.Options) sdkclient.Options) *ClientPool

func (*ClientPool) Clients added in v1.13.0

func (cp *ClientPool) Clients() map[ClientPoolKey]sdkclient.Client

Clients returns a snapshot of the cached clients.

func (*ClientPool) Close

func (cp *ClientPool) Close()

func (*ClientPool) DefaultCreateClient added in v1.13.0

func (cp *ClientPool) DefaultCreateClient(
	ctx context.Context,
	spec v1alpha1.ConnectionSpec,
	temporalNamespace, k8sNamespace, identity string,
) (CachedClient, error)

DefaultCreateClient is the built-in creation path: parse the referenced Secret, build SDK options, dial, health-check, and return a CachedClient whose IsValid checks mTLS cert expiry. It reads CustomizeClientOptions from the pool struct; a wrapper using a custom CreateClientFn owns construction entirely.

func (*ClientPool) EvictClient added in v1.6.0

func (cp *ClientPool) EvictClient(key ClientPoolKey)

EvictClient removes and closes the client for key. No-op if absent.

func (*ClientPool) GetClient added in v1.13.0

func (cp *ClientPool) GetClient(
	ctx context.Context,
	spec v1alpha1.ConnectionSpec,
	temporalNamespace, k8sNamespace, identity string,
) (sdkclient.Client, ClientPoolKey, error)

GetClient returns a cached or newly created Temporal client for the connection spec. The pool caches the result; on a cache hit, IsValid decides whether the cached client is still usable.

func (*ClientPool) SetClientForTesting added in v1.3.0

func (cp *ClientPool) SetClientForTesting(key ClientPoolKey, c sdkclient.Client)

SetClientForTesting caches a stub client, bypassing the dial. Test-only.

func (*ClientPool) TLSCertPool added in v1.10.0

func (cp *ClientPool) TLSCertPool(caCert []byte) (*x509.CertPool, error)

TLSCertPool returns the system CA pool with caCert appended. Returns (nil, nil) when caCert is empty, leaving RootCAs unset so Go falls back to the system pool.

type ClientPoolKey

type ClientPoolKey struct {
	HostPort            string
	TLSServerName       string
	Namespace           string            // Temporal namespace
	SecretName          string            // invalidate cache when the secret name changes
	TLSCACertSecretName string            // invalidate cache when TLS.CACertSecretRef changes
	AuthMode            v1alpha1.AuthMode // invalidate cache when the auth mode changes
}

type CreateClientFunc added in v1.13.0

type CreateClientFunc func(
	ctx context.Context,
	spec v1alpha1.ConnectionSpec,
	temporalNamespace, k8sNamespace, identity string,
) (CachedClient, error)

CreateClientFunc creates a Temporal SDK client for a connection spec: secret parsing, options, dialing, and health check. The pool caches the returned CachedClient.

type DialError added in v1.13.0

type DialError struct{ Err error }

func (*DialError) Error added in v1.13.0

func (e *DialError) Error() string

func (*DialError) Unwrap added in v1.13.0

func (e *DialError) Unwrap() error

Jump to

Keyboard shortcuts

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