temporal 核心概念
所属分类 temporal
浏览量 1008
根据官方文档整理
https://docs.temporal.io/docs/temporal-explained/introduction/
Workflows
Activities
Task Queues & Workers
Signals and Queries 信号和查询 (信号通知异步 查询是同步的)
Timeouts & Retry Policy 超时和重试策略
Visibility
A Temporal Application is a set of Temporal Workflow Executions
The Temporal Platform consists of a Temporal Cluster and Worker Processes.
Together these components create a runtime for Workflow Executions.
Temporal SDK
Signals and Queries enable data to be sent to or extracted from a Workflow Execution
Task Queues and Workers are tightly coupled components.
A Task is the context that a Worker needs to progress with a specific Workflow Execution or Activity Execution.
There are two types of Tasks:
Activity Task
Workflow Task
A Task Queue is lightweight, dynamically allocated queue that one or more Worker Entities poll for Tasks.
Task Queues do not have any ordering guarantees.
It is possible to have a Task that stays in a Task Queue for a period of time,
if there is a backlog that wasn't drained for that time.
Signals and Queries are messages that provide data to and request data from a running Workflow Execution.
Signals and Queries are frequently used together.
A Query is a synchronous operation that is used to report the state of a Workflow Execution.
查询是一个同步操作 用于获取工作流执行状态
Query handling logic must be read-only and cannot change the Workflow Execution state in any way
查询 是 只读的
In many SDKs the Temporal Client exposes a predefined _stack_track_ Query that returns the stack trace of all the threads owned by that Workflow Execution.
This is a great way to troubleshoot a Workflow Execution in production.
查询获取 工作流 堆栈信息 ,用于排查问题
There is a built in Query type named __stack_trace
A Signal is an external asynchronous request to a Workflow Execution.
Signal 是 外部对 Workflow 的 异步请求 ,修改 Workflow 状态
A Signal can not return data to the caller, use Queries for that
Signal没有返回值 , 可使用查询 返回结果
Signal Header
Recipient: Workflow Execution (Namespace + Workflow Id)
unique Id
queueName
Signal Body Any encodable data
Workflow functions listen for Signals by the Signal name
Timeouts and Retry Policy
Timeout settings and a Retry Policy provide fine controls over specific steps of Workflow Executions and Activity Executions
Workflow Execution Timeout
Workflow Run Timeout
Workflow Task Timeout
Schedule-To-Start Timeout
Start-To-Close Timeout
Schedule-To-Close Timeout
Heartbeat Timeout
final GreetingActivities activities = Workflow.newActivityStub(GreetingActivities.class,
ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(2))
// 设置最大重试次数 ,否则会重试直到最大次数
.setRetryOptions(RetryOptions.newBuilder().setMaximumAttempts(1).build())
.build());
public final class RetryOptions {
private static final double DEFAULT_BACKOFF_COEFFICIENT = 2.0;
private static final int DEFAULT_MAXIMUM_MULTIPLIER = 100;
private Builder(RetryOptions options) {
if (options == null) {return;}
this.backoffCoefficient = options.getBackoffCoefficient();
this.maximumAttempts = options.getMaximumAttempts();
this.initialInterval = options.getInitialInterval();
this.maximumInterval = options.getMaximumInterval();
this.doNotRetry = options.getDoNotRetry();
}
getDoNotRetry
List of application failures types to not retry.
initialInterval
Interval of the first retry. If coefficient is 1.0 then it is used for all retries
backoffCoefficient
Coefficient used to calculate the next retry interval.
The next retry interval is previousinterval multiplied by this coefficient.
Must be 1 or larger. Default is 2.0.
temporal Java 例子说明
Temporal Platform Visibility
the subsystems and APIs that enable an operator to view Workflow Executions that currently exist within a Cluster.
用于查看工作流执行情况
list Workflow Executions by a predefined set of filters
根据过滤条件获取 执行中的工作流列表
Open Workflow Executions can be filtered by a time constraint and either a Workflow Type, Workflow Id, or Run Id
Execution Status
Completed, Failed, Timed Out, Terminated, Cancelled, Continued-As-New
Advanced Visibility
integrated with Elasticsearch
上一篇
下一篇
使用 Dockerfile 构建 gohttphello server 镜像
temporal Java 例子说明
go 包管理工具 go mod
git 分支操作
IDEA 常用设置
idea 当前文件查找 快捷键失效