← Code Exchange

Go Code Generation with Temporal & Protobufs

protoc-gen-go-temporal is a protoc plugin for generating typed Temporal clients and workers in Go from protobuf schemas. This plugin allows:

  • workflow authors to configure sensible defaults and guardrails
  • simplifies the implementation and testing of Temporal workers
  • and streamlines integration by providing typed client SDKs and a generated CLI application

Here's the "Temporal @ Hashicorp" Replay talk where we announced the plugin and gave a quick introduction to it:

Features

Generated Client with:

  • methods for executing workflows, queries, signals, and updates
  • methods for cancelling or terminating workflows
  • default client.StartWorkflowOptions and client.UpdateWorkflowWithOptionsRequest
  • dynamic workflow ids, update ids, and search attributes via Bloblang expressions
  • default timeouts, id reuse policies, retry policies, wait policies

Generated Worker resources with:

  • functions for calling activities and local activities from workflows
  • functions for executing child workflows and signalling external workflows
  • default workflow.ActivityOptions, workflow.ChildWorkflowOptions
  • default timeouts, parent cose policies, retry policies

Optional CLI with:

  • commands for executing workflows, synchronously or asynchronously
  • commands for starting workflows with signals, synchronously or asynchronously
  • commands for querying existing workflows
  • commands for sending signals to existing workflows
  • typed flags for conventiently specifying workflow, query, and signal inputs

Generated Cross-Namespace (XNS) helpers: [Experimental]

  • with support for invoking a service's workflows, queries, signals, and updates from workflows in a different temporal namespace

Generated Remote Codec Server helpers

Generated Markdown Documentation

Inspiration

This project was inspired by Chad Retz's awesome github.com/cretz/temporal-sdk-go-advanced and Jacob LeGrone's excellent Replay talk on Temporal @ Datadog

💖 Community code generationprotobuf

About the Author

Chris Ludden

Chris Ludden

Temporal