Skip to main content

Temporal Client - Go SDK

View Markdown

A Temporal Client enables you to communicate with the Temporal Service. Communication with a Temporal Service lets you perform actions such as starting Workflow Executions, sending Signals to Workflow Executions, sending Queries to Workflow Executions, getting the results of a Workflow Execution, and providing Activity Task Tokens.

For Standalone Activities, a Temporal Client can also start and manage Standalone Activities directly, without involving a Workflow.

This page shows you how to do the following using the Go SDK with the Temporal Client:

caution

A Temporal Client cannot be initialized and used inside a Workflow. However, it is acceptable and common to use a Temporal Client inside an Activity to communicate with a Temporal Service.

Connect to development Temporal Service​

Use the Dial() API available in the go.temporal.io/sdk/client package to create a Client. The Dial() API expects connection options such as the Temporal Server address, the Namespace to connect to, and Transport Layer Security (TLS) configuration. You can specify these options in the function call, or specify them using environment variables or a configuration file. We recommend you use environment variables or a configuration file to manage these connection options securely.

Versioning Requirements

Environment variable and configuration file support were added in Go SDK v1.28.0.

When you are running a Temporal Service locally, such as the Temporal CLI, the connection options you must provide are minimal.

If you don't provide HostPort, the Client defaults the address and port number to 127.0.0.1:7233, which is the port of the development Temporal Service. If you don't set a custom Namespace name in the Namespace field, the client connects to the default Namespace.