跳到正文
Skillpedia
API 与服务器(后端)48k · #5956

temporal-golang-pro

它能做什么

这个工具可以帮助你使用 Temporal Go SDK 构建稳健可靠的分布式系统。即使程序暂时出现故障,它也能确保流程正确运行,并帮助你配置安全性和性能。

适用场景

  • ✓当你构建需要持久状态和可靠编排的微服务时。
  • ✓当你要实现长时间运行的流程(数天或数月)或复杂的事务模式时。
  • ✓当你要优化系统的安全性(mTLS)和性能时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/temporal-golang-pro/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/temporal-golang-pro/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我如何在 Go 中为我的分布式系统设置一个带有 mTLS 的安全工作节点?”

每周 5 个新技能,1 分钟读完。

工作原理

该工具会分析你的需求,并应用 Temporal Go SDK 的最佳实践。它会验证代码是否具有确定性(即相同输入总是产生相同结果),并帮助你配置工作节点、管理复杂工作流,以及可靠地测试整个系统。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Temporal Go SDK (temporal-golang-pro)

Overview

Expert-level guide for building resilient, scalable, and deterministic distributed systems using the Temporal Go SDK. This skill transforms vague orchestration requirements into production-grade Go implementations, focusing on durable execution, strict determinism, and enterprise-scale worker configuration.

When to Use This Skill

  • Designing Distributed Systems: When building microservices that require durable state and reliable orchestration.
  • Implementing Complex Workflows: Using the Go SDK to handle long-running processes (days/months) or complex Saga patterns.
  • Optimizing Performance: When workers need fine-tuned concurrency, mTLS security, or custom interceptors.
  • Ensuring Reliability: Implementing idempotent activities, graceful error handling, and sophisticated retry policies.
  • Maintenance & Evolution: Versioning running workflows or performing zero-downtime worker updates.

Do not use this skill when

  • Using Temporal with other SDKs (Python, Java, TypeScript) - refer to their specific -pro skills.
  • The task is a simple request/response without durability or coordination needs.
  • High-level design without implementation (use workflow-orchestration-patterns).

Step-by-Step Guide

  1. Gather Context: Proactively ask for:
    • Target Temporal Cluster (Cloud vs. Self-hosted) and Namespace.
    • Task Queue names and expected throughput.
    • Security requirements (mTLS paths, authentication).
    • Failure modes and desired retry/timeout policies.
  2. Verify Determinism: Before suggesting workflow code, verify against these 5 Rules:
    • No native Go concurrency (goroutines).
    • No native time (time.Now, time.Sleep).
    • No non-deterministic map iteration (must sort keys).
    • No direct external I/O or network calls.
    • No non-deterministic random numbers.
  3. Implement Incrementally: Start with shared Protobuf/Data classes, then Activities, then Workflows, and finally Workers.
  4. Leverage Resources: If the implementation requires advanced patterns (Sagas, Interceptors, Replay Testing), explicitly refer to the implementation playbook and testing strategies.

Capabilities

Go SDK Implementation

  • Worker Management: Deep knowledge of worker.Options, including MaxConcurrentActivityTaskPollers, WorkerStopTimeout, and StickyScheduleToStartTimeout.
  • Interceptors: Implementing Client, Worker, and Workflow interceptors for cross-cutting concerns (logging, tracing, auth).
  • Custom Data Converters: Integrating Protobuf, encrypted payloads, or custom JSON marshaling.

Advanced Workflow Patterns

  • Durable Concurrency: Using workflow.Go, workflow.Channel, and workflow.Selector instead of native primitives.
  • Versioning: Implementing safe code evolution using workflow.GetVersion and workflow.GetReplaySafeLogger.
  • Large-scale Processing: Pattern for ContinueAsNew to manage history size limits (defaults: 50MB or 50K events).
  • Child Workflows: Managing lifecycle, cancellation, and parent-child signal propagation.

Testing & Observability

  • Testsuite Mastery: Using WorkflowTestSuite for unit and functional testing with deterministic time control.
  • Mocking: Sophisticated activity and child workflow mocking strategies.
  • Replay Testing: Validating code changes against production event histories.
  • Metrics: Configuring Prometheus/OpenTelemetry exporters for worker performance tracking.

Examples

Example 1: Versioned Workflow (Deterministic)

// Note: imports omitted. Requires 'go.temporal.io/sdk/workflow', 'go.temporal.io/sdk/temporal', and 'time'.
func SubscriptionWorkflow(ctx workflow.Context, userID string) error {
    // 1. Versioning for logic evolution (v1 = DefaultVersion)
    v := workflow.GetVersion(ctx, "billing_logic", workflow.DefaultVersion, 2)

    for i := 0; i < 12; i++ {
        ao := workflow.ActivityOptions{
            StartToCloseTimeout: 5 * time.Minute,
            RetryPolicy: &temporal.RetryPolicy{MaximumAttempts: 3},
        }
        ctx = workflow.WithActivityOptions(ctx, ao)

        // 2. Activity Execution (Always handle errors)
        err := workflow.ExecuteActivity(ctx, ChargePaymentActivity, userID).Get(ctx, nil)
        if err != nil {
            workflow.GetLogger(ctx).Error("Payment failed", "Error", err)
            return err
        }


…
常见问题

什么是分布式系统?

分布式系统由多台计算机协同工作来完成任务,例如大型网站或支付服务。

这里的“确定性”是什么意思?

意思是,一个流程在相同输入下运行,总是会得到相同的输出,而不依赖外部或随机因素。

什么是 mTLS?

这是一种更高级的安全机制,确保客户端和服务器双方都相互验证身份,就像双方在通信前完成的一次“暗号握手”。

详情

作者的原始描述

Use when building durable distributed systems with Temporal Go SDK. Covers deterministic workflow rules, mTLS worker configs, and advanced patterns.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5956
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能