Azure / Azure/azure-functions-java-library

@CosmosDBInput ignores partitionKey

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

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

area:java-functions
主要言語
Java
スター
45
フォーク
49
PR マージ指標
30日以内にマージされた PR はありません

説明

In my Micronaut Azure Function I am using a binding @CosmosDBInput for event-sourcing like this:

public class ChatRoomFunction extends AzureFunction {

  @FunctionName("handleCommand")
  public HttpResponseMessage handleCommand(
    @HttpTrigger(
      name = "req",
      methods = HttpMethod.POST,
      authLevel = AuthorizationLevel.ANONYMOUS)
    final HttpRequestMessage<Command> request,
    @CosmosDBInput(
      name = "events",
      connectionStringSetting = CONNECTION_STRING,
      databaseName = DATABASE_NAME,
      collectionName = "events",
      partitionKey = "events--{id}") final List<Event> events,
    final ExecutionContext context
  ) {
     // function body intentionally left out
  }
}

// with

public class Command {
  private UUID id;

  // more fields, getters, setters
}

// and

public class Event {
  private String streamId; // this is the CosmosDB partition key

  // more fields, getters, setters
}

Before, I tried doing this using @TableInput which seemed to worked fine.
Now I've switched to CosmosDB and for some reason it seems to ignore my @CosmosDBInput's partitionKey value.

Expected: events should contain a list of only Events having a certain streamId as matched by the binding parameter of the request body, i.e. id.

Actual: events contains a list of ALL Events present in the events collection.

Am I missing something here? This is what the partitionKey is for, right?

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

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

調査の方向性

handleCommand の @CosmosDBInput アノテーションから始め、partitionKey の値がリクエストボディからどのように解決されるかを追跡します。events コレクションを使った例を再現し、その後、binding が要求された streamId でフィルタリングするかどうかを確認します。binding が一致するイベントのみを返すか、サポートされる動作を明確に文書化できれば完了です。

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

評価

技術スタック
azure, java
領域
backend, cloud
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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