Proposal: synchronous (non-blocking) flag evaluation API alongside the async one

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
静か
技術スタック
rust
領域
api, backend

調査の方向性

まず既存の Client::get_value/getdetails と FeatureProvider::resolve* のエントリーポイントを読み、次にプロバイダーの状態に tokio::sync::RwLock がどのように使われているかを確認します。async API を維持したまま、maintainer が sync trait、Client のアクセサー、状態戦略、cargo-feature の判断について合意すれば完了です。

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

説明

Summary

The Rust SDK currently exposes an async-only evaluation API: every Client::get_*_value/get_*_details method and every FeatureProvider::resolve_* method is async. This proposal asks for a complementary synchronous evaluation path for providers whose resolution is purely in-memory, without removing or changing the existing async API.

Motivation

Our backend servers resolve flags from a local, periodically refreshed in-memory cache (with state polled from S3 in a background task,). For such providers, evaluation itself performs no I/O , yet the async-only API still forces us to set.await through dozens of unrelated functions, even though the underlying evaluation is a hash-map lookup.

The Java SDK also provides a sync-first API (client.getBooleanValue(...))

Spec compliance

Requirement 1.4.12
states:

The client SHOULD provide asynchronous or non-blocking mechanisms for flag evaluation.

This is a SHOULD, not a MUST.

Design sketch (for discussion)

  1. SyncFeatureProvider trait: same surface as FeatureProvider but with plain fn resolve_*_value(...) -> EvaluationResult<ResolutionDetails<T>> methods. Intended for providers backed by local state (files, env vars, in-memory caches).
  2. Sync accessors on Client (e.g. get_bool_value_sync(...) -> EvaluationResult<bool>): available when the bound provider implements SyncFeatureProvider;
  3. Sync-safe internal state for the sync path: the sync accessors must not go through tokio::sync::RwLock::blocking_*. Options include a
    std::sync::RwLock/arc-swap-style snapshot for provider registration.

Open questions:

  • Should this live behind a cargo feature (e.g. sync) to keep the default dependency footprint unchanged?

If the maintainers are open to this direction, I'm happy to work on a PR implementing the agreed design.

主要言語
Rust
スター
53
フォーク
15
平均マージ
1分
マージ済み PR(30日)
16

環境構築

はじめの一歩

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

open-feature/rust-sdk のほかの issue

open-feature/rust-sdk の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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