stdtemporalfx

package
v0.0.165 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Provide

func Provide() fx.Option

func RegisterMain

func RegisterMain[T generatedClient, W, A, O any](
	queueName string,
	newClientFn func(client.Client, ...O) T,
	regFn func(worker tworker.Worker, wf W, act A),
	opts ...O,
) fx.Option

Register registers workflow and activity implementations.

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 ClientInterceptor

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

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

func NewClientInterceptor

func NewClientInterceptor(val protovalidate.Validator) *ClientInterceptor

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"`
}

type Registration

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

Registration describes registering of workflow and activities with a worker.

type RegistrationFunc

type RegistrationFunc func(w tworker.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
	ClientInterceptor *ClientInterceptor
},
) (*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 WorkerInterceptor

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

func NewWorkerInterceptor

func NewWorkerInterceptor(
	val protovalidate.Validator,
	logs *zap.Logger,
) *WorkerInterceptor

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

func (*WorkerInterceptor) InterceptActivity

InterceptActivity intercepts activities.

func (*WorkerInterceptor) InterceptWorkflow

InterceptWorkflow intercepts workflows.

type Workers

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

func NewWorkers

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

	Client                 *Temporal
	Logger                 *zap.Logger
	WorkerInterceptor      *WorkerInterceptor
	MainWorkerRegistration *Registration `name:"main"`
},
) (*Workers, error)

func (*Workers) Start

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

func (*Workers) Stop

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

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