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
- func DeleteRunnerNexusEndpoint(runnerID string) error
- func EnsureNamespaceReady(namespace string) error
- func EnsureRunnerNamespace(app core.App, runnerID string)
- func FetchNamespaces(app core.App) ([]string, error)
- func RunnerNamespaceIDs(app core.App) ([]string, error)
- func StartAllWorkersByNamespace(app core.App, namespace string)
- func StartRunnerNamespaceWorkers(app core.App, namespace string) error
- func StopAllWorkers()
- func StopAllWorkersByNamespace(namespace string)
- func StopRunnerNamespaceWorkers(app core.App, runnerID string)
- func TemporalClientSetupHook(app *pocketbase.PocketBase)
- func TemporalWorkersDisabled() bool
- func WorkersHook(app *pocketbase.PocketBase)
Constants ¶
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
DeleteRunnerNexusEndpoint deletes the Nexus endpoint of the runner with record ID runnerID. An endpoint that does not exist is not an error.
func EnsureNamespaceReady ¶
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
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 RunnerNamespaceIDs ¶ added in v1.338.0
RunnerNamespaceIDs lists the record IDs of the runners that are not disabled.
func StartRunnerNamespaceWorkers ¶ added in v1.338.0
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
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.