hooks

package
v1.339.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 36 Imported by: 0

Documentation

Overview

Package hooks provides functionality to manage and run Temporal workers for executing workflows and activities in a distributed system. It includes functions to start workers, register workflows and activities, and handle workflow execution.

Index

Constants

View Source
const TemporalWorkersDisabledEnv = "CREDIMI_TEMPORAL_WORKERS_DISABLED"

TemporalWorkersDisabledEnv disables Temporal namespace creation and worker registration when set to a truthy value (1, true, yes). Intended for faster local API/UI boots that do not need pipelines or workflows.

Variables

This section is empty.

Functions

func DeleteRunnerNexusEndpoint added in v1.338.0

func DeleteRunnerNexusEndpoint(runnerID string) error

DeleteRunnerNexusEndpoint deletes the Nexus endpoint of the runner with record ID runnerID. An endpoint that does not exist is not an error.

func EnsureNamespaceReady

func EnsureNamespaceReady(namespace string) error

EnsureNamespaceReady registers the namespace when missing, waits until Temporal describes it and registers Credimi's custom search attributes on it. It retries with backoff for up to 90 seconds.

func EnsureRunnerNamespace added in v1.338.0

func EnsureRunnerNamespace(app core.App, runnerID string)

EnsureRunnerNamespace prepares the namespace of the runner with record ID runnerID while it is not disabled: registers it with Credimi's search attributes and starts its workers, then, if the stored runner is still not disabled, marks it served by this process and ready on the record (mobilerunner.MarkRunnerNamespaceReady); otherwise it stops the workers again. A namespace already served only gets its record flag restored. Calls for one runner run one at a time, with StopRunnerNamespaceWorkers; a call while another for the same runner is queued or running returns at once.

func FetchNamespaces

func FetchNamespaces(app core.App) ([]string, error)

func RunnerNamespaceIDs added in v1.338.0

func RunnerNamespaceIDs(app core.App) ([]string, error)

RunnerNamespaceIDs lists the record IDs of the runners that are not disabled.

func StartAllWorkersByNamespace

func StartAllWorkersByNamespace(app core.App, namespace string)

func StartRunnerNamespaceWorkers added in v1.338.0

func StartRunnerNamespaceWorkers(app core.App, namespace string) error

StartRunnerNamespaceWorkers starts the worker set of a runner namespace: one worker on PipelineTaskQueue that hosts the workflows of the runner's devices (Prepare a mobile device, Clean up a mobile device, the mobile automation step workflow and the action author session), the mobiledevice Nexus service the pipeline calls them through, and the activities those workflows schedule on PipelineTaskQueue.

func StopAllWorkers

func StopAllWorkers()

StopAllWorkers stops the workers of every namespace concurrently and waits for them to drain.

func StopAllWorkersByNamespace

func StopAllWorkersByNamespace(namespace string)

StopAllWorkersByNamespace cancels the namespace's workers and waits up to workerStopWait for them to drain.

func StopRunnerNamespaceWorkers added in v1.338.0

func StopRunnerNamespaceWorkers(app core.App, runnerID string)

StopRunnerNamespaceWorkers stops the workers of the namespace of the runner with record ID runnerID unless the stored runner is enabled again. The record update that disabled the runner already cleared its readiness. The namespace stays in Temporal; its histories expire by retention. Calls for one runner run one at a time, with EnsureRunnerNamespace, and are never skipped.

func TemporalClientSetupHook

func TemporalClientSetupHook(app *pocketbase.PocketBase)

TemporalClientSetupHook validates the Temporal secrets encryption key and the Temporal JWT signing keys, writes the signing keys' public JWKS file that Temporal reads (temporalauth.JWKSDir), and routes Temporal SDK logs through the PocketBase logger, and to OpenTelemetry when export is on, when the server starts. It must be bound before any other hook that creates Temporal clients on serve.

func TemporalWorkersDisabled

func TemporalWorkersDisabled() bool

TemporalWorkersDisabled reports whether Temporal workers should stay offline.

func WorkersHook

func WorkersHook(app *pocketbase.PocketBase)

WorkersHook sets up a hook for the PocketBase application to create the namespaces for already existing orgs and starts the workers when the server starts. It binds a function to the OnServe event, which logs a message indicating that workers are starting and then asynchronously starts all workers by calling StartAllWorkers in a separate goroutine.

Parameters:

  • app: The PocketBase application instance to which the hook is attached.

Types

This section is empty.

Jump to

Keyboard shortcuts

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