Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions docs/go-quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ title: Quick Start
This topic helps you install the Temporal server and implement a workflow.

## Install Temporal Server Locally
To run samples locally you need to run Temporal server locally using [instructions](/docs/installing-server).

To run samples locally you need to run Temporal server locally using [instructions](/docs/installing-server).

## Start with an empty directory

Expand All @@ -23,16 +24,18 @@ cd tutorial-go-sdk
## Initialize Go Modules and SDK Package Dependency

Initialize Go modules

```
> go mod init github.com/temporalio/tutorial-go-sdk
go: creating new go.mod: module github.com/temporalio/tutorial-go-sdk
```

Add dependency to Temporal Go SDK

```bash
> go get go.temporal.io/temporal@v0.23.1
go: downloading go.temporal.io/temporal v0.23.1
go: go.temporal.io/temporal upgrade => v0.23.1
> go get go.temporal.io/temporal@v0.25.0
go: downloading go.temporal.io/temporal v0.25.0
go: go.temporal.io/temporal upgrade => v0.25.0
```

## Implement Activities
Expand Down Expand Up @@ -182,7 +185,7 @@ Run your worker app which hosts workflow and activity implementations
## Start workflow execution

```bash
> docker run --network=host --rm temporalio/tctl:0.23.1 wf start --tl tutorial_tl -w Greet_Temporal_1 --wt Greetings --et 3600 --dt 10
> docker run --network=host --rm temporalio/tctl:0.25.0 wf start --tl tutorial_tl -w Greet_Temporal_1 --wt Greetings --et 3600 --dt 10
Started Workflow Id: Greet_Temporal_1, run Id: b4f8957a-565c-40ad-8495-15a41338f8f4
```

Expand All @@ -201,4 +204,4 @@ Greeting sent to user: Temporal
## Try Go SDK Samples

Check [Go SDK Samples](https://github.com/temporalio/temporal-go-samples)
and try simple Temporal usage scenario.
and try simple Temporal usage scenario.
2 changes: 1 addition & 1 deletion docs/go-sdk-video-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,5 @@ func main() {
Commands:

```bash
docker run --network=host --rm temporalio/tctl:0.23.1 wf start --tl tutorial_tl -w Greet_Temporal_1 --wt Greetings --et 3600 --dt 10
docker run --network=host --rm temporalio/tctl:0.25.0 wf start --tl tutorial_tl -w Greet_Temporal_1 --wt Greetings --et 3600 --dt 10
```
8 changes: 4 additions & 4 deletions docs/installing-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Follow the docker-compose installation instructions found here: [https://docs.do
Download the Temporal docker-compose file to preferred location (i.e. `quick_start` directory):

```bash
curl -L https://github.com/temporalio/temporal/releases/download/v0.23.1/docker.tar.gz | tar -xz --strip-components 1 docker/docker-compose.yml
curl -L https://github.com/temporalio/temporal/releases/download/v0.25.0/docker.tar.gz | tar -xz --strip-components 1 docker/docker-compose.yml

ls
# docker-compose.yml
Expand All @@ -31,7 +31,7 @@ The output should look similar to:

```
Creating network "quick_start_default" with the default driver
Pulling temporal (temporalio/temporal-auto-setup:0.23.1)...
Pulling temporal (temporalio/temporal-auto-setup:0.25.0)...
...
...
temporal_1 | Description: Default namespace for Temporal Server
Expand Down Expand Up @@ -59,5 +59,5 @@ At this point Temporal Server is running! You can also see the web interface on
## Write Workflows and Activities using Client SDK

Try out [Java SDK](/docs/java-quick-start).
Try out [Go SDK](/docs/go-quick-start).

Try out [Go SDK](/docs/go-quick-start).
143 changes: 115 additions & 28 deletions docs/java-quick-start.md

Large diffs are not rendered by default.

51 changes: 47 additions & 4 deletions docs/learn-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@ workflow, show workflow history, and signal workflow.

## Using the CLI

The Temporal CLI can be used directly from the Docker Hub image *temporalio/tctl* or by building the CLI tool
The Temporal CLI can be used directly from the Docker Hub image _temporalio/tctl_ or by building the CLI tool
locally.

Example of using the docker image to describe a namespace:

```
docker run --rm temporalio/tctl:0.23.1 --namespace samples-namespace namespace describe
docker run --rm temporalio/tctl:0.25.0 --namespace samples-namespace namespace describe
```

On Docker versions 18.03 and later, you may get a "connection refused" error. You can work around this by setting the host to "host.docker.internal" (see [here](https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds) for more info).

```
docker run --network=host --rm temporalio/tctl:0.23.1 --namespace samples-namespace namespace describe
docker run --network=host --rm temporalio/tctl:0.25.0 --namespace samples-namespace namespace describe
```

To build the CLI tool locally, clone the [Temporal server repo](https://github.com/temporalio/temporal) and run
`make bins`. This produces an executable called `tctl`. With a local build, the same command to
describe a namespace would look like this:

```
./tctl --namespace samples-namespace namespace describe
```
Expand All @@ -40,6 +42,7 @@ Setting environment variables for repeated parameters can shorten the CLI comman
- **TEMPORAL_CLI_NAMESPACE** - default workflow namespace, so you don't need to specify `--namespace`

## Quick Start

Run `./tctl` for help on top level commands and global options
Run `./tctl namespace` for help on namespace operations
Run `./tctl workflow` for help on workflow operations
Expand All @@ -49,30 +52,39 @@ Run `./tctl tasklist` for help on tasklist operations
**Note:** make sure you have a Temporal server running before using CLI

### Namespace operation examples

- Register a new namespace named "samples-namespace":

```
./tctl --namespace samples-namespace namespace register --global_namespace false
# OR using short alias
./tctl --ns samples-namespace n re --gd false
```

- View "samples-namespace" details:

```
./tctl --namespace samples-namespace namespace describe
```

### Workflow operation examples

The following examples assume the TEMPORAL_CLI_NAMESPACE environment variable is set.

#### Run workflow

Start a workflow and see its progress. This command doesn't finish until workflow completes.

```
./tctl workflow run --tl helloWorldGroup --wt main.Workflow --et 60 -i '"temporal"'

# view help messages for workflow run
./tctl workflow run -h
```

Brief explanation:
To run a workflow, the user must specify the following:

1. Tasklist name (--tl)
2. Workflow type (--wt)
3. Execution start to close timeout in seconds (--et)
Expand All @@ -85,11 +97,13 @@ and takes a string as input with the `-i '"temporal"'` parameter. Single quotes
(Run `make && ./bin/helloworld -m worker` in temporal-go-samples to start the worker)

#### Show running workers of a tasklist

```
./tctl tasklist desc --tl helloWorldGroup
```

#### Start workflow

```
./tctl workflow start --tl helloWorldGroup --wt main.Workflow --et 60 -i '"temporal"'

Expand All @@ -99,15 +113,17 @@ and takes a string as input with the `-i '"temporal"'` parameter. Single quotes
# for a workflow with multiple inputs, separate each json with space/newline like
./tctl workflow start --tl helloWorldGroup --wt main.WorkflowWith3Args --et 60 -i '"your_input_string" 123 {"Name":"my-string", "Age":12345}'
```

The workflow `start` command is similar to the `run` command, but immediately returns the workflow_id and
run_id after starting the workflow. Use the `show` command to view the workflow's history/progress.

##### Reuse the same workflow id when starting/running a workflow

Use option `--workflowidreusepolicy` or `--wrp` to configure the workflow id reuse policy.
**Option 0 AllowDuplicateFailedOnly:** Allow starting a workflow execution using the same workflow Id when a workflow with the same workflow Id is not already running and the last execution close state is one of *[terminated, cancelled, timedout, failed]*.
**Option 0 AllowDuplicateFailedOnly:** Allow starting a workflow execution using the same workflow Id when a workflow with the same workflow Id is not already running and the last execution close state is one of _[terminated, cancelled, timedout, failed]_.
**Option 1 AllowDuplicate:** Allow starting a workflow execution using the same workflow Id when a workflow with the same workflow Id is not already running.
**Option 2 RejectDuplicate:** Do not allow starting a workflow execution using the same workflow Id as a previous workflow.

```
# use AllowDuplicateFailedOnly option to start a workflow
./tctl workflow start --tl helloWorldGroup --wt main.Workflow --et 60 -i '"temporal"' --wid "<duplicated workflow id>" --wrp 0
Expand All @@ -117,14 +133,17 @@ Use option `--workflowidreusepolicy` or `--wrp` to configure the workflow id reu
```

##### Start a workflow with a memo

Memos are immutable key/value pairs that can be attached to a workflow run when starting the workflow. These are
visible when listing workflows. More information on memos can be found
[here](/docs/learn-workflow-filtering#memo-vs-search-attributes).

```
tctl wf start -tl helloWorldGroup -wt main.Workflow -et 60 -i '"temporal"' -memo_key ‘“Service” “Env” “Instance”’ -memo ‘“serverName1” “test” 5’
```

#### Show workflow history

```
./tctl workflow show -w 3ea6b242-b23c-4279-bb13-f215661b4717 -r 866ae14c-88cf-4f1e-980f-571e031d71b0
# a shortcut of this is (without -w -r flag)
Expand All @@ -137,6 +156,7 @@ tctl wf start -tl helloWorldGroup -wt main.Workflow -et 60 -i '"temporal"' -memo
```

#### Show workflow execution information

```
./tctl workflow describe -w 3ea6b242-b23c-4279-bb13-f215661b4717 -r 866ae14c-88cf-4f1e-980f-571e031d71b0
# a shortcut of this is (without -w -r flag)
Expand All @@ -149,6 +169,7 @@ tctl wf start -tl helloWorldGroup -wt main.Workflow -et 60 -i '"temporal"' -memo
```

#### List closed or open workflow executions

```
./tctl workflow list

Expand All @@ -165,6 +186,7 @@ Use **--query** to list workflows with SQL like query:
This will return all open workflows with workflowType as "main.SampleParentWorkflow".

#### Query workflow execution

```
# use custom query type
./tctl workflow query -w <wid> -r <rid> --qt <query-type>
Expand All @@ -176,6 +198,7 @@ This will return all open workflows with workflowType as "main.SampleParentWorkf
```

#### Signal, cancel, terminate workflow

```
# signal
./tctl workflow signal -w <wid> -r <rid> -n <signal-name> -i '"signal-value"'
Expand All @@ -186,14 +209,17 @@ This will return all open workflows with workflowType as "main.SampleParentWorkf
# terminate
./tctl workflow terminate -w <wid> -r <rid> --reason
```

Terminating a running workflow execution will record a WorkflowExecutionTerminated event as the closing event in the history. No more decision tasks will be scheduled for a terminated workflow execution.
Canceling a running workflow execution will record a WorkflowExecutionCancelRequested event in the history, and a new decision task will be scheduled. The workflow has a chance to do some clean up work after cancellation.

#### Signal, cancel, terminate workflows as a batch job

Batch job is based on List Workflow Query(**--query**). It supports signal, cancel and terminate as batch job type.
For terminating workflows as batch job, it will terminte the children recursively.

Start a batch job(using signal as batch type):

```
tctl --ns samples-namespace wf batch start --query "WorkflowType='main.SampleParentWorkflow' AND CloseTime=missing" --reason "test" --bt signal --sig testname
This batch job will be operating on 5 workflows.
Expand All @@ -204,29 +230,38 @@ Please confirm[Yes/No]:yes
}

```

You need to remember the JobId or use List command to get all your batch jobs:

```
tctl --ns samples-namespace wf batch list
```

Describe the progress of a batch job:

```
tctl --ns samples-namespace wf batch desc -jid <batch-job-id>
```

Terminate a batch job:

```
tctl --ns samples-namespace wf batch terminate -jid <batch-job-id>
```

Note that the operation performed by a batch will not be rolled back by terminating the batch. However, you can use reset to rollback your workflows.

#### Restart, reset workflow

The Reset command allows resetting a workflow to a particular point and continue running from there.
There are a lot of use cases:

- Rerun a failed workflow from the beginning with the same start parameters.
- Rerun a failed workflow from the failing point without losing the achieved progress(history).
- After deploying new code, reset an open workflow to let the workflow run to different flows.

You can reset to some predefined event types:

```
./tctl workflow reset -w <wid> -r <rid> --reset_type <reset_type> --reason "some_reason"
```
Expand All @@ -236,24 +271,31 @@ You can reset to some predefined event types:
- LastContinuedAsNew: reset to the end of the history for the previous run.

If you are familiar with the Temporal history event, You can also reset to any decision finish event by using:

```
./tctl workflow reset -w <wid> -r <rid> --event_id <decision_finish_event_id> --reason "some_reason"
```

Some things to note:

- When reset, a new run will be kicked off with the same workflowId. But if there is a running execution for the workflow(workflowId), the current run will be terminated.
- decision_finish_event_id is the Id of events of the type: DecisionTaskComplete/DecisionTaskFailed/DecisionTaskTimeout.
- To restart a workflow from the beginning, reset to the first decision task finish event.

To reset multiple workflows, you can use batch reset command:

```
./tctl workflow reset-batch --input_file <file_of_workflows_to_reset> --reset_type <reset_type> --reason "some_reason"
```

#### Recovery from bad deployment -- auto-reset workflow

If a bad deployment lets a workflow run into a wrong state, you might want to reset the workflow to the point that the bad deployment started to run. But usually it is not easy to find out all the workflows impacted, and every reset point for each workflow. In this case, auto-reset will automatically reset all the workflows given a bad deployment identifier.

Let's get familiar with some concepts. Each deployment will have an identifier, we call it "**Binary Checksum**" as it is usually generated by the md5sum of a binary file. For a workflow, each binary checksum will be associated with an **auto-reset point**, which contains a **runId**, an **eventID**, and the **created_time** that binary/deployment made the first decision for the workflow.

To find out which **binary checksum** of the bad deployment to reset, you should be aware of at least one workflow running into a bad state. Use the describe command with **--reset_points_only** option to show all the reset points:

```
./tctl wf desc -w <WorkflowId> --reset_points_only
+----------------------------------+--------------------------------+--------------------------------------+---------+
Expand All @@ -266,6 +308,7 @@ To find out which **binary checksum** of the bad deployment to reset, you should
```

Then use this command to tell Temporal to auto-reset all workflows impacted by the bad deployment. The command will store the bad binary checksum into namespace info and trigger a process to reset all your workflows.

```
./tctl --ns <YourNamespace> namespace update --add_bad_binary aae748fdc557a3f873adbe1dd066713f --reason "rollback bad deployment"
```
Expand Down
8 changes: 4 additions & 4 deletions docs/learn-workflow-filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type StartWorkflowOptions struct {
}
```

In the Java client, the *WorkflowOptions.Builder* has similar methods for [memo](https://static.javadoc.io/com.uber.cadence/cadence-client/2.6.0/com/uber/cadence/client/WorkflowOptions.Builder.html#setMemo-java.util.Map-) and [search attributes](https://static.javadoc.io/com.uber.cadence/cadence-client/2.6.0/com/uber/cadence/client/WorkflowOptions.Builder.html#setSearchAttributes-java.util.Map-).
In the Java client, the _WorkflowOptions.Builder_ has similar methods for [memo](https://static.javadoc.io/com.uber.cadence/cadence-client/2.6.0/com/uber/cadence/client/WorkflowOptions.Builder.html#setMemo-java.util.Map-) and [search attributes](https://static.javadoc.io/com.uber.cadence/cadence-client/2.6.0/com/uber/cadence/client/WorkflowOptions.Builder.html#setSearchAttributes-java.util.Map-).

Some important distinctions between memo and search attributes:

Expand Down Expand Up @@ -95,7 +95,7 @@ Note that **Keyword** and **String** are concepts taken from Elasticsearch. Each
For example, key RunId with value "2dd29ab7-2dd8-4668-83e0-89cae261cfb1"

- as a **Keyword** will only be matched by RunId = "2dd29ab7-2dd8-4668-83e0-89cae261cfb1" (or in the future with [regular expressions](https://github.com/uber/cadence/issues/1137))
- as a **String** will be matched by RunId = "2dd8", which may cause unwanted matches
- as a **String** will be matched by RunId = "2dd8", which may cause unwanted matches

**Note:** String type can not be used in Order By query.

Expand Down Expand Up @@ -166,7 +166,7 @@ map[string]interface{}{
}
```

There is no support for removing a field. To achieve a similar effect, set the field to a sentinel value. For example, to remove “CustomKeywordField”, update it to “impossibleVal”. Then searching `CustomKeywordField != ‘impossibleVal’` will match workflows with CustomKeywordField not equal to "impossibleVal", which **includes** workflows without the CustomKeywordField set.
There is no support for removing a field. To achieve a similar effect, set the field to a sentinel value. For example, to remove “CustomKeywordField”, update it to “impossibleVal”. Then searching `CustomKeywordField != ‘impossibleVal’` will match workflows with CustomKeywordField not equal to "impossibleVal", which **includes** workflows without the CustomKeywordField set.

Use `workflow.GetInfo` to get current search attributes.

Expand Down Expand Up @@ -282,7 +282,7 @@ Queries are supported in [Temporal Web](https://github.com/temporalio/temporal-w
## Local Testing

1. Increase Docker memory to higher than 6GB. Navigate to Docker -> Preferences -> Advanced -> Memory
2. Get the Temporal Docker compose file. Run `curl -L https://github.com/temporalio/temporal/releases/download/v0.23.1/docker.tar.gz | tar -xz --strip-components 1 docker/docker-compose-es.yml`
2. Get the Temporal Docker compose file. Run `curl -L https://github.com/temporalio/temporal/releases/download/v0.25.0/docker.tar.gz | tar -xz --strip-components 1 docker/docker-compose-es.yml`
3. Start Temporal Docker (which contains Apache Kafka, Apache Zookeeper, and Elasticsearch) using `docker-compose -f docker-compose-es.yml up`
4. From the Docker output log, make sure Elasticsearch and Temporal started correctly. If you encounter an insufficient disk space error, try `docker system prune -a --volumes`
5. Register a local namespace and start using it. `tctl --ns samples-namespace n re`
Expand Down
Loading