temporalclient

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Configs = configset.Set[Config]{
		Default: &Config{
			Monitor: defaultMonitorConfig,
		},
		Dev: &Config{
			Monitor:               defaultMonitorConfig,
			StartDevServerIfNotUp: true,
			DevServer: testsuite.DevServerOptions{
				LogLevel:   zapcore.WarnLevel.String(),
				EnableUI:   true,
				DBFilename: filepath.Join(xdg.DataHomeDir(), "temporal_dev.sqlite"),
			},
			EnableHelperRedirect: true,
		},
		Test: &Config{
			Monitor:              defaultMonitorConfig,
			AlwaysStartDevServer: true,
			DevServer: testsuite.DevServerOptions{
				LogLevel: zapcore.WarnLevel.String(),
				EnableUI: true,
			},
		},
	}
)

Functions

func IsWorkflowContextAsGoContext added in v0.9.2

func IsWorkflowContextAsGoContext(ctx context.Context) bool

func New

func New(cfg *Config, z *zap.Logger) (Client, LazyTemporalClient, error)

func NewFromClient added in v0.3.1

func NewFromClient(cfg *MonitorConfig, z *zap.Logger, tclient client.Client) (Client, LazyTemporalClient, error)

func NewWorker added in v0.9.2

func NewWorker(l *zap.Logger, client client.Client, qname string, cfg WorkerConfig) worker.Worker

NewWorker creates a new Temporal worker. If the worker is disabled, returns nil.

func NewWorkflowContextAsGOContext

func NewWorkflowContextAsGOContext(ctx workflow.Context) context.Context

Creates a new GO context that gets the Done() signal from the workflow context. Performing long running operations in the returned context will block the workflow execution, which will result in Temporal's deadlock detector kicking in and kickking your butt.

func WithActivityOptions added in v0.9.2

func WithActivityOptions(wctx workflow.Context, qname string, ac ActivityConfig) workflow.Context

func WithoutDeadlockDetection added in v0.9.4

func WithoutDeadlockDetection(f func())

WithoutDeadlockDetection allows to execute the `f`, which does not perform any temporal operations (ie calling temporal using `wctx`) and thus might trigger the temporal deadlock detector.

This function is useful for `f`s that we know are slow and should not have their result cached by temporal - they need to run every workflow invocation, including during replays. Example usage is resource allocation.

See also https://github.com/temporalio/temporal/issues/6546. Blame Maxim, not me.

Types

type ActivityConfig added in v0.9.2

type ActivityConfig struct {
	ScheduleToCloseTimeout time.Duration `koanf:"schedule_to_close_timeout"`
	StartToCloseTimeout    time.Duration `koanf:"start_to_close_timeout"`
	HeartbeatTimeout       time.Duration `koanf:"heartbeat_timeout"`
	ScheduleToStartTimeout time.Duration `koanf:"schedule_to_start_timeout"`
}

Common way to define configuration that can be used in multiple modules, saving the need to repeat the same configuration in each module.

func (ActivityConfig) ToOptions added in v0.9.2

func (ac ActivityConfig) ToOptions(qname string) workflow.ActivityOptions

func (ActivityConfig) With added in v0.9.2

other overrides self.

type Client

type Client interface {
	Start(context.Context) error
	Stop(context.Context) error
	Temporal() client.Client
	TemporalAddr() (frontend, ui string)
	healthreporter.HealthReporter
}

type Config

type Config struct {
	Monitor MonitorConfig `koanf:"monitor"`

	AlwaysStartDevServer  bool   `koanf:"always_start_dev_server"`
	StartDevServerIfNotUp bool   `koanf:"start_dev_server_if_not_up"`
	HostPort              string `koanf:"hostport"`
	Namespace             string `koanf:"namespace"`

	// DevServer.ClientOptions is not used.
	DevServer testsuite.DevServerOptions `koanf:"dev_server"`
	TLS       tlsConfig                  `koanf:"tls"`

	EnableHelperRedirect bool `koanf:"enable_helper_redirect"`
}

type LazyTemporalClient added in v0.9.2

type LazyTemporalClient = func() client.Client

type MonitorConfig added in v0.3.1

type MonitorConfig struct {
	CheckHealthInterval time.Duration   `koanf:"check_health_interval"`
	CheckHealthTimeout  time.Duration   `koanf:"check_health_timeout"`
	LogLevel            zap.AtomicLevel `koanf:"log_level"`
}

type WorkerConfig added in v0.9.2

type WorkerConfig struct {
	Disable                 bool          `koanf:"disable"`
	WorkflowDeadlockTimeout time.Duration `koanf:"workflow_deadlock_timeout"`
}

Common way to define configuration that can be used in multiple modules, saving the need to repeat the same configuration in each module.

func (WorkerConfig) With added in v0.9.2

func (wc WorkerConfig) With(other WorkerConfig) WorkerConfig

other overrides self.

type WorkflowConfig added in v0.9.2

type WorkflowConfig struct {
	WorkflowTaskTimeout time.Duration `koanf:"workflow_task_timeout"`
}

Common way to define configuration that can be used in multiple modules, saving the need to repeat the same configuration in each module.

func (WorkflowConfig) ToStartWorkflowOptions added in v0.9.2

func (wc WorkflowConfig) ToStartWorkflowOptions(qname, id, sum string, memo map[string]string) client.StartWorkflowOptions

func (WorkflowConfig) With added in v0.9.2

other overrides self.

type WorkflowContextAsGoContext

type WorkflowContextAsGoContext struct {
	workflow.Context
	// contains filtered or unexported fields
}

func (*WorkflowContextAsGoContext) Deadline

func (wctx *WorkflowContextAsGoContext) Deadline() (time.Time, bool)

func (*WorkflowContextAsGoContext) Done

func (wctx *WorkflowContextAsGoContext) Done() <-chan struct{}

func (*WorkflowContextAsGoContext) Err

func (wctx *WorkflowContextAsGoContext) Err() error

func (*WorkflowContextAsGoContext) Value

func (wctx *WorkflowContextAsGoContext) Value(key any) any

Jump to

Keyboard shortcuts

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