Methods for loading, capturing, and serializing Temporal workflow execution histories for use in replay testing.
Methods for loading, capturing, and serializing Temporal workflow execution histories for use in replay testing.
(->json history)(->json history pretty-print?)Serializes a WorkflowExecutionHistory to a JSON string.
Arguments:
| Value | Description | Type | Default |
|---|---|---|---|
history | The workflow execution history to serialize | WorkflowExecutionHistory | |
pretty-print? | Whether to format JSON output with indentation | boolean | true |
(spit "order.json" (->json history))
(spit "order.json" (->json history false))
Serializes a `WorkflowExecutionHistory` to a JSON string. Arguments: | Value | Description | Type | Default | | --------------- | ------------------------------------------------------- | ------------------------ | ------- | | `history` | The workflow execution history to serialize | WorkflowExecutionHistory | | | `pretty-print?` | Whether to format JSON output with indentation | boolean | `true` | ```clojure (spit "order.json" (->json history)) (spit "order.json" (->json history false)) ``` See also [[from-json]], [[fetch]]
(fetch client workflow-id)Fetches a workflow execution history from a live Temporal server.
Arguments:
| Value | Description | Type |
|---|---|---|
client | WorkflowClient from temporal.client.core/create-client | WorkflowClient |
workflow-id | ID of the workflow whose history to fetch | String |
(let [h (fetch client "workflow-id-123")]
(spit "test/resources/histories/order.json" (->json h)))
See also from-json, from-file, from-resource, ->json
Fetches a workflow execution history from a live Temporal server. Arguments: | Value | Description | Type | | ------------- | -------------------------------------------------------------- | ------------------------------------------------------- | | `client` | WorkflowClient from [[temporal.client.core/create-client]] | WorkflowClient | | `workflow-id` | ID of the workflow whose history to fetch | String | ```clojure (let [h (fetch client "workflow-id-123")] (spit "test/resources/histories/order.json" (->json h))) ``` See also [[from-json]], [[from-file]], [[from-resource]], [[->json]]
(from-file file)Reads a workflow execution history from a file.
Accepts a string path, java.io.File, or java.nio.file.Path.
Arguments:
| Value | Description | Type |
|---|---|---|
file | Path to a JSON file containing the workflow history | String, java.io.File, or java.nio.file.Path |
(from-file "test/resources/histories/order.json")
(from-file (clojure.java.io/file "test/resources/histories/order.json"))
See also from-json, from-resource, fetch, ->json
Reads a workflow execution history from a file. Accepts a string path, `java.io.File`, or `java.nio.file.Path`. Arguments: | Value | Description | Type | | ------ | ----------------------------------------------------- | ------------------------------------------------ | | `file` | Path to a JSON file containing the workflow history | String, `java.io.File`, or `java.nio.file.Path` | ```clojure (from-file "test/resources/histories/order.json") (from-file (clojure.java.io/file "test/resources/histories/order.json")) ``` See also [[from-json]], [[from-resource]], [[fetch]], [[->json]]
(from-json json)(from-json json workflow-id)Parses a JSON string into a WorkflowExecutionHistory.
Arguments:
| Value | Description | Type | Default |
|---|---|---|---|
json | JSON string containing the serialized workflow execution history | String | |
workflow-id | Optional workflow ID override, replaces any ID embedded in JSON | String | nil |
(from-json "{...history json...}")
(from-json "{...history json...}" "my-workflow-id")
See also from-file, from-resource, fetch, ->json
Parses a JSON string into a `WorkflowExecutionHistory`.
Arguments:
| Value | Description | Type | Default |
| ------------- | ---------------------------------------------------------------- | ------ | ------- |
| `json` | JSON string containing the serialized workflow execution history | String | |
| `workflow-id` | Optional workflow ID override, replaces any ID embedded in JSON | String | nil |
```clojure
(from-json "{...history json...}")
(from-json "{...history json...}" "my-workflow-id")
```
See also [[from-file]], [[from-resource]], [[fetch]], [[->json]](from-resource name)Reads a workflow execution history from a classpath resource.
Throws ex-info with {:resource name} if the resource is not found on the classpath.
Arguments:
| Value | Description | Type |
|---|---|---|
name | Classpath resource name for the JSON-serialized workflow history | String |
(from-resource "histories/order-workflow.json")
Reads a workflow execution history from a classpath resource.
Throws `ex-info` with `{:resource name}` if the resource is not found on the classpath.
Arguments:
| Value | Description | Type |
| ------ | ------------------------------------------------------------------ | ------ |
| `name` | Classpath resource name for the JSON-serialized workflow history | String |
```clojure
(from-resource "histories/order-workflow.json")
```
See also [[from-json]], [[from-file]], [[fetch]], [[->json]]cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |