connector

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultHeartbeatInterval is the connector heartbeat interval used when the
	// binding payload does not provide an override.
	DefaultHeartbeatInterval = 30 * time.Second
	// DefaultLocalDialTimeout is the timeout for connector-to-local-runtime dials.
	DefaultLocalDialTimeout = 5 * time.Second
	// DefaultHubDialTimeout is the timeout for connector-to-hub dials.
	DefaultHubDialTimeout = 10 * time.Second
)
View Source
const (
	// DefaultMaxMessageSize is the fallback max receive/send message size for connector gRPC links.
	DefaultMaxMessageSize = 10 * 1024 * 1024
	// DefaultChannelBufferSize is the fallback buffered channel depth for connector stream loops.
	DefaultChannelBufferSize = 16
	// DefaultMessageTimeout is the fallback per-message timeout for connector runtime operations.
	DefaultMessageTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func CallWithTimeout

func CallWithTimeout(ctx context.Context, timeout time.Duration, opName string, fn func(context.Context) error) error

CallWithTimeout executes fn with a derived context that carries the timeout. The callback should honor the provided context so any background work can unwind promptly after timeout or cancellation.

func ChannelBufferSize

func ChannelBufferSize(env Env, def int) int

ChannelBufferSize resolves the buffered channel size used by stream loops.

func ChannelSendTimeout

func ChannelSendTimeout(env Env) time.Duration

ChannelSendTimeout resolves the optional send timeout env.

func ClientCallOptions

func ClientCallOptions(env Env, defaultRecv, defaultSend int) []grpc.CallOption

ClientCallOptions returns dialing call options derived from env overrides.

func DialTimeout

func DialTimeout(env Env, def time.Duration) time.Duration

DialTimeout resolves the shared GRPC dial timeout env with fallback.

func HangTimeout

func HangTimeout(env Env) time.Duration

HangTimeout resolves the passive hang timeout env.

func HubCredentials

func HubCredentials(env Env) (credentials.TransportCredentials, error)

HubCredentials builds TLS credentials from the shared env vars.

func ListenLocalEndpoint

func ListenLocalEndpoint(endpoint string) (net.Listener, error)

ListenLocalEndpoint normalizes tcp/unix endpoints and returns a listener.

func MessageTimeout

func MessageTimeout(env Env, def time.Duration) time.Duration

MessageTimeout resolves the connector message timeout env.

func RecvWithTimeout

func RecvWithTimeout[T any](
	ctx context.Context,
	timeout time.Duration,
	opName string,
	fn func(context.Context) (T, error),
) (T, error)

RecvWithTimeout executes fn with a derived context that carries the timeout. The callback should honor the provided context so any background work can unwind promptly after timeout or cancellation.

func ServerOptions

func ServerOptions(env Env, defaultRecv, defaultSend int) []grpc.ServerOption

ServerOptions returns standard gRPC server options derived from env overrides.

func WaitForReady

func WaitForReady(ctx context.Context, conn *grpc.ClientConn) error

WaitForReady blocks until the connection reports connectivity.Ready or the context expires.

Types

type Config

type Config struct {
	LocalEndpoint            string
	LocalServerName          string
	HubEndpoint              string
	StoryRunName             string
	Namespace                string
	StepID                   string
	LocalDialTimeout         time.Duration
	HubDialTimeout           time.Duration
	Binding                  coretransport.BindingPayload
	BindingHeartbeatInterval time.Duration
	Generation               int32
}

Config captures the ambient connector runtime settings.

func LoadConfigFromEnv

func LoadConfigFromEnv(env Env) (*Config, error)

LoadConfigFromEnv builds a Config from shared connector env vars.

type Env

type Env interface {
	Lookup(key string) string
}

Env provides a minimal interface for resolving environment variables.

var OSEnv Env = EnvFunc(os.Getenv)

OSEnv resolves variables from the host process environment.

type EnvFunc

type EnvFunc func(string) string

EnvFunc adapts functions like os.Getenv to the Env interface.

func (EnvFunc) Lookup

func (f EnvFunc) Lookup(key string) string

Lookup returns the variable value for EnvFunc.

type RuntimeTunables

type RuntimeTunables struct {
	MessageTimeout     time.Duration
	ChannelSendTimeout time.Duration
	HangTimeout        time.Duration
	ChannelBufferSize  int
}

RuntimeTunables captures connector/channel runtime knobs shared across repos.

func RuntimeTunablesFromEnv

func RuntimeTunablesFromEnv(env Env, defaults RuntimeTunables) RuntimeTunables

RuntimeTunablesFromEnv resolves runtime knobs from env vars, falling back to the supplied defaults (or the package defaults when the provided values are zero). Env values always take precedence over defaults.

Jump to

Keyboard shortcuts

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