microsoft / microsoft/durabletask-java

Improved orchestrator and activity input/output handling

オープン
#15 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Java
スター
29
フォーク
18
平均マージ
1日 10時間
マージ済み PR(30日)
2

説明

Background

The current TaskOrchestration and TaskActivity interfaces require implementations to use the context object to receive inputs. Consider the following example (copied from the integration tests):

final String orchestratorName = "SingleActivity";
final String activityName = "Echo";
final String input = Instant.now().toString();
DurableTaskGrpcWorker worker = this.createWorkerBuilder()
    .addOrchestrator(orchestratorName, ctx -> {
        String activityInput = ctx.getInput(String.class);
        String output = ctx.callActivity(activityName, activityInput, String.class).get();
        ctx.complete(output);
    })
    .addActivity(activityName, ctx -> {
        return String.format("Hello, %s!", ctx.getInput(String.class));
    })
    .buildAndStart();

This design, while it works, has a few issues:

  1. The fetching of inputs is not type-safe because the call to ctx.getInput(String.class) could fail if the input isn't actually a string.
  2. The call to ctx.getInput() isn't intuitive, making the programming model harder for developers to learn.
  3. The call to ctx.complete(output) is both unintuitive and inconsistent with how activity functions are defined.

This issue tracks improving the programming model to make processing inputs and outputs more intuitive and type-safe.

Proposal

The proposal is to change these interface definitions so that a developer could write the following, simpler orchestration and activity implementations:

final String orchestratorName = "SingleActivity";
final String activityName = "Echo";
final String input = Instant.now().toString();
DurableTaskGrpcWorker worker = this.createWorkerBuilder()
    .addOrchestrator(orchestratorName, (ctx, activityInput) -> {
        return ctx.callActivity(activityName, activityInput, String.class).get();
    })
    .addActivity(activityName, (ctx, name) -> {
        return String.format("Hello, %s!", name);
    })
    .buildAndStart();

The differences are:

  • The orchestrator and activity functions have the input passed to them explicitly.
  • The orchestrator can use the return value to set the output.

This results in a simpler, more intuitive programming model and is also consistent with the proposed C# programming model.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、TaskOrchestration インターフェイスと TaskActivity インターフェイス、および issue で参照されている統合テストの例を確認します。現在、入力と出力がコンテキストを通じてどのように受け渡されているかを追跡し、その後、実装が型付き入力を受け取り、示されているように出力を返すようにプログラミングモデルを更新します。統合テストでは、提案された使用方法を示す必要があります。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
backend-api-design
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。