stdtemporalfx

package
v0.0.185 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Provide

func Provide() fx.Option

func ProvideClient added in v0.0.166

func ProvideClient[T generatedClient, O any](
	newClientFn func(client.Client, ...O) T,
	opts ...O,
) fx.Option

func ProvideRegistration added in v0.0.166

func ProvideRegistration[W, A any](
	queueName string,
	regFn func(worker worker.Worker, wf W, act A),
) fx.Option

Types

type Client

type Client[T generatedClient] struct{ W T }

Client wraps a generated Workflow client. The wrapping simply exists so we can set the underlying temporal client in a "onStart" hook.

type Config

type Config struct {
	// temporal server grpc
	TemporalHostPort string `env:"TEMPORAL_HOST_PORT" envDefault:"localhost:7233"`
	// temporal namespace for this deployment
	TemporalNamespace string `env:"TEMPORAL_NAMESPACE" envDefault:"default"`
	// API key for authentication with the cluster.
	TemporalAPIKey string `env:"TEMPORAL_API_KEY"`
	// create and use randomly-named namespace, mainly for testing.
	CreateAndUseRandomNamespace bool `env:"CREATE_AND_USE_RANDOM_NAMESPACE"`
	// remove the namespace when the client shuts down, only taken into account with: CREATE_AND_USE_RANDOM_NAMESPACE
	AutoRemoveNamespace bool `env:"AUTO_REMOVE_NAMESPACE"`
	// in some cases the workers are not necessary to be run (such as when the code is also run as a Lambda)
	DisableWorkers bool `env:"DISABLE_WORKERS"`
}

type DefaultClientInterceptor added in v0.0.185

type DefaultClientInterceptor struct {
	interceptor.ClientInterceptorBase
	// contains filtered or unexported fields
}

DefaultClientInterceptor validates workflow & signal/update args on the caller side.

func NewDefaultClientInterceptor added in v0.0.185

func NewDefaultClientInterceptor(val protovalidate.Validator) *DefaultClientInterceptor

func (*DefaultClientInterceptor) InterceptClient added in v0.0.185

type DefaultWorkerInterceptor added in v0.0.185

type DefaultWorkerInterceptor struct {
	interceptor.InterceptorBase
	// contains filtered or unexported fields
}

func NewDefaultWorkerInterceptor added in v0.0.185

func NewDefaultWorkerInterceptor(
	val protovalidate.Validator,
	logs *zap.Logger,
) *DefaultWorkerInterceptor

NewDefaultWorkerInterceptor initializes an interceptor for our worker. It implements cross-cutting concerns for all activity and workflow execution. Such as input validation.

func (*DefaultWorkerInterceptor) InterceptActivity added in v0.0.185

InterceptActivity intercepts activities.

func (*DefaultWorkerInterceptor) InterceptWorkflow added in v0.0.185

InterceptWorkflow intercepts workflows.

type Registration

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

Registration describes registering of workflow and activities with a worker.

type Temporal

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

Temporal holds a reference to the Temporal Temporal.

func New

func New(par struct {
	fx.In
	fx.Lifecycle

	Config Config
	Logger *zap.Logger

	// propagators and interceptrs, the order matter so we can't use value groups (directly).
	Propagators  []workflow.ContextPropagator    `optional:"true"`
	Interceptors []interceptor.ClientInterceptor `optional:"true"`
},
) (*Temporal, error)

New inits the Temporal client.

func (*Temporal) CheckHealth

func (c *Temporal) CheckHealth(ctx context.Context) error

func (*Temporal) Namespace

func (c *Temporal) Namespace() string

Namespace this client is using.

func (*Temporal) Start

func (c *Temporal) Start(ctx context.Context) (err error)

Start connects to the Temporal server.

func (*Temporal) Stop

func (c *Temporal) Stop(ctx context.Context) (err error)

Stop disconnects from the Temporal server.

type Workers

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

Workers represent the set of Temporal workers.

func NewWorkers

func NewWorkers(par struct {
	fx.In
	fx.Lifecycle
	Logger   *zap.Logger
	Temporal *Temporal

	Interceptors  []interceptor.WorkerInterceptor
	Registrations []*Registration `group:"registrations"`
},
) (*Workers, error)

NewWorkers inits a new set of workers.

func (*Workers) Start

func (w *Workers) Start(context.Context) error

Start the registered workers.

func (*Workers) Stop

func (w *Workers) Stop(context.Context) error

Stop the workers.

Directories

Path Synopsis
internal
v1
Code generated by protoc-gen-go_temporal.
Code generated by protoc-gen-go_temporal.

Jump to

Keyboard shortcuts

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