Temporal

The temporal integration provides an opinionated way to interact with Temporal for workflow orchestration for helix services.

Trace attributes

The temporal integration sets the following trace attributes:

  • temporal.server.address
  • temporal.namespace
  • span.kind

When applicable, these attributes can be set as well:

  • temporal.worker.taskqueue
  • temporal.workflow.id
  • temporal.workflow.run_id
  • temporal.workflow.namespace
  • temporal.workflow.type
  • temporal.workflow.attempt
  • temporal.activity.id
  • temporal.activity.type
  • temporal.activity.attempt
  • temporal.schedule.id
  • temporal.search.query
  • temporal.signal.name

Example:

temporal.server.address: "temporal.mydomain.tld"
temporal.namespace: "default"
temporal.worker.taskqueue: "demo"
temporal.workflow.namespace: "default"
temporal.workflow.type: "hello_world"
temporal.workflow.attempt: 2
span.kind: "internal"

Usage

Install the Go module with:

$ go get go.nunchi.studio/helix/integration/temporal

Simple example on how to import, configure, and use the integration:

import (
  "go.nunchi.studio/helix/integration/temporal"
  "go.nunchi.studio/helix/service"

  "go.temporal.io/sdk/activity"
  "go.temporal.io/sdk/workflow"
)

func main() {
  cfg := temporal.Config{
    Address:   "localhost:7233",
    Namespace: "default",
    Worker: temporal.ConfigWorker{
      Enabled:   true,
      TaskQueue: "demo",
    },
  }

  _, w, err := temporal.Connect(cfg)
  if err != nil {
    return err
  }

  w.RegisterWorkflow(YourWorkflowDefinition, workflow.RegisterOptions{
    Name: "workflow",
  })

  w.RegisterActivity(YourSimpleActivityDefinition, activity.RegisterOptions{
    Name: "activity",
  })

  if err := service.Start(); err != nil {
    panic(err)
  }

  if err := service.Close(); err != nil {
    panic(err)
  }
}

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the repository. Once we merge it, the changes will be reflected on the website the next time it is deployed. Thank you for your contributions!
Built by
Nunchi