microsoft / microsoft/durabletask-java

Add Durable Task middleware support

Đang mở
#285 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Needs: Triage :mag:
Ngôn ngữ chính
Java
Star
29
Fork
18
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
2

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng việc đọc đặc tả middleware cross-SDK được liên kết và hướng dẫn người dùng .NET, sau đó kiểm tra các API durable worker/builder trong Java SDK này. Sử dụng các điểm vào middleware orchestration và activity được đề xuất để lập bản đồ thiết kế, bao gồm các tính năng ngữ cảnh và quy tắc xác thực. Công việc được coi là hoàn tất khi các bài kiểm thử chấp nhận được liệt kê, tài liệu và phần tích hợp các tính năng của host đã được triển khai mà không thay đổi wire hoặc protobuf.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
backend-api-design
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.