Skip to main content

ScopeStrategy

Trait ScopeStrategy 

Source
pub trait ScopeStrategy: Send + Sync {
    // Required method
    fn determine_scope(
        &self,
        context: &TaskContext,
        worker_id: WorkerId,
    ) -> WorkerScope;
}
Expand description

Scope 決定戦略

Manager が Worker に渡す情報のスコープを決定する戦略。 外部から注入可能で、状況に応じた動的なスコープ制御を実現する。

§使用例

// 固定スコープ(全 Worker に同じスコープ)
let strategy = FixedScopeStrategy::new(WorkerScope::Minimal);

// 適応的スコープ(状況に応じて変化)
let strategy = AdaptiveScopeStrategy::new()
    .with_default(WorkerScope::Minimal)
    .with_on_escalation(WorkerScope::SelfDetail);

Required Methods§

Source

fn determine_scope( &self, context: &TaskContext, worker_id: WorkerId, ) -> WorkerScope

Worker の Scope を決定

TaskContext と WorkerId を受け取り、その Worker に適用する WorkerScope を返す。

Implementors§