microsoft / microsoft/durabletask-java

Add Durable Task middleware support

未關閉
#285 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

Needs: Triage :mag:
主要語言
Java
星號
29
分支
18
平均合併
1 天 10 小時
30 天內合併 PR
2

描述

Summary

Track adding SDK-level Durable Task middleware support to the Java SDK, aligned with the .NET reference implementation.

Reference spec: https://github.com/microsoft/durabletask-dotnet/blob/feature/durable-task-middleware/doc/cross-sdk-middleware.md
.NET user guide: https://github.com/microsoft/durabletask-dotnet/blob/feature/durable-task-middleware/doc/durable-task-middleware.md
Motivation: https://github.com/Azure/azure-functions-durable-extension/issues/3054

The spec may shift until the .NET v1 implementation is merged. This issue is intended to track the Java design and implementation work so it can follow the same durable middleware contract with idiomatic API names.

Proposed shape

Names are illustrative, not final API commitments.

workerBuilder.useOrchestrationMiddleware((ctx, next) -> {
    if (!ctx.isReplaying()) {
        logger.info("starting orchestration {}", ctx.getInstanceId());
    }

    return next.invoke(ctx);
});

workerBuilder.useActivityMiddleware((ctx, next) -> {
    Optional<Object> cached = cache.tryGet(ctx.getName(), ctx.getInput());
    if (cached.isPresent()) {
        ctx.setResult(cached.get());
        return CompletableFuture.completedFuture(null);
    }

    return next.invoke(ctx);
});

Design points to cover

  • Builder-level registration APIs for orchestration and activity middleware.
  • Registration ordering: first registered middleware runs outermost and unwinds last.
  • Context interfaces that expose durable task name, instance ID, version/parent/tags where available, input, raw input where available, replay state for orchestrations, features, and result after next.
  • A feature collection keyed by Class<T> or another type-safe Java abstraction.
  • Integration with dependency injection frameworks where present, without requiring a particular DI container.
  • Orchestration middleware determinism guidance for replay, including replay-safe logging and avoiding nondurable CompletableFuture/threading usage, wall-clock time, random values, file/network I/O, and mutable process state.
  • Activity middleware short-circuiting through an explicit setResult API.
  • Host integration pattern for Azure Functions or other hosts to attach invocation context through features instead of durable middleware depending on host middleware internals.

Acceptance criteria

  • Orchestration and activity middleware APIs are exposed at the durable worker/builder level.
  • Middleware executes in registration order and unwinds in reverse order.
  • Orchestration middleware must call next.invoke(ctx) exactly once when completing successfully; missing or duplicate calls are rejected where feasible.
  • Activity middleware can call next.invoke(ctx) once or short-circuit only through ctx.setResult(...); duplicate next is invalid.
  • Host-specific objects can be passed through features without serialization into durable history.
  • Documentation covers replay determinism and the difference between durable middleware and host/Functions middleware.
  • Tests cover registration ordering, context population, feature access, orchestration next-call validation, and activity short-circuiting.
  • No wire protocol or protobuf changes are required.
  • Entity middleware is out of scope for v1.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先閱讀連結的跨 SDK 中介軟體規格和 .NET 使用者指南,然後檢查此 Java SDK 中的 durable worker/builder API。使用提議的 orchestration 和 activity 中介軟體進入點來對應設計,包括內容功能和驗證規則。實作列出的驗收測試、文件以及 host 功能整合,且不進行 wire 或 protobuf 變更,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
backend-api-design
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
冷清
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。