pub struct Orchestrator { /* private fields */ }Expand description
Orchestrator - メインループ管理
Implementations§
Source§impl Orchestrator
impl Orchestrator
Sourcepub fn validate(&self) -> Result<(), SwarmError>
pub fn validate(&self) -> Result<(), SwarmError>
Orchestrator の設定を検証
run_task() を呼ぶ前にこのメソッドで設定を検証できます。 run_task() 内でも同様のチェックが行われますが、事前に検証したい場合に使用します。
§Errors
SwarmError::NoWorkers: Worker が設定されていないSwarmError::MissingDependencyGraph: DependencyGraph のソースが設定されていない
§Example
let orchestrator = OrchestratorBuilder::new()
.add_worker(worker)
.batch_invoker(invoker)
.build(runtime);
// 事前検証
orchestrator.validate()?;
// タスク実行
let result = orchestrator.run_task(task)?;Source§impl Orchestrator
impl Orchestrator
Sourcepub fn new(
workers: Vec<Box<dyn WorkerAgent>>,
config: SwarmConfig,
runtime: Handle,
) -> Self
pub fn new( workers: Vec<Box<dyn WorkerAgent>>, config: SwarmConfig, runtime: Handle, ) -> Self
新規作成
Sourcepub fn with_analyzer(self, analyzer: Box<dyn Analyzer>) -> Self
pub fn with_analyzer(self, analyzer: Box<dyn Analyzer>) -> Self
Analyzer を設定
Sourcepub fn add_manager(self, manager: Box<dyn ManagerAgent>) -> Self
pub fn add_manager(self, manager: Box<dyn ManagerAgent>) -> Self
Manager を追加
Sourcepub fn with_batch_invoker(self, invoker: Box<dyn BatchInvoker>) -> Self
pub fn with_batch_invoker(self, invoker: Box<dyn BatchInvoker>) -> Self
BatchInvoker を設定
Sourcepub fn with_dependency_provider(
self,
provider: Box<dyn DependencyGraphProvider>,
) -> Self
pub fn with_dependency_provider( self, provider: Box<dyn DependencyGraphProvider>, ) -> Self
DependencyGraphProvider を設定
run_task() 時に ExplorationSpace がない場合、 このプロバイダーを使って DependencyGraph を自動生成する。
Sourcepub fn enable_partitioning(&mut self)
pub fn enable_partitioning(&mut self)
Worker パーティショニングを有効化
各 Manager に Worker を均等に割り当てる。 Manager ごとに担当 Worker のみの TaskContext を渡すため、 大規模システムでのスケーラビリティが向上する。
§呼び出しタイミング
全ての Manager を追加した後に呼び出すこと。
Sourcepub fn dependency_graph(&self) -> Option<&DependencyGraph>
pub fn dependency_graph(&self) -> Option<&DependencyGraph>
DependencyGraph への参照を取得
ExplorationSpaceV2 に設定されている DependencyGraph を返す。 学習データ保存時に action_order を抽出するために使用。
Sourcepub fn run_task(&mut self, task: SwarmTask) -> Result<SwarmResult, SwarmError>
pub fn run_task(&mut self, task: SwarmTask) -> Result<SwarmResult, SwarmError>
タスクを設定してメインループを実行
SwarmTask を Extensions に登録してから run() を実行する。
Manager は state.shared.extensions.get::<SwarmTask>() でタスクを読み取れる。
§Errors
SwarmError::MissingDependencyGraph: DependencyGraph を生成できなかった
§Example
let task = SwarmTask::new("Find the auth handler")
.with_target_path("/path/to/repo");
let result = orchestrator.run_task(task)?;Sourcepub fn run(&mut self) -> SwarmResult
pub fn run(&mut self) -> SwarmResult
メインループを実行
Sourcepub fn request_terminate(&mut self)
pub fn request_terminate(&mut self)
外部から終了を要求
Sourcepub fn termination_judge(&self) -> &TerminationJudge
pub fn termination_judge(&self) -> &TerminationJudge
TerminationJudge への参照を取得
Sourcepub fn termination_judge_mut(&mut self) -> &mut TerminationJudge
pub fn termination_judge_mut(&mut self) -> &mut TerminationJudge
TerminationJudge への可変参照を取得
Sourcepub fn state(&self) -> &SwarmState
pub fn state(&self) -> &SwarmState
State への参照を取得
Sourcepub fn async_system(&self) -> &AsyncTaskSystem
pub fn async_system(&self) -> &AsyncTaskSystem
AsyncTaskSystem への参照を取得
Sourcepub fn learned_provider(&self) -> Option<&SharedLearnedProvider>
pub fn learned_provider(&self) -> Option<&SharedLearnedProvider>
LearnedProvider への参照を取得
Auto Trait Implementations§
impl Freeze for Orchestrator
impl !RefUnwindSafe for Orchestrator
impl Send for Orchestrator
impl Sync for Orchestrator
impl Unpin for Orchestrator
impl !UnwindSafe for Orchestrator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more