pub struct WorkerBuilder { /* private fields */ }Expand description
Builder for configuring and creating a Worker.
§Examples
use std::sync::Arc;
use std::time::Duration;
use ironflow_worker::WorkerBuilder;
use ironflow_core::providers::claude::ClaudeCodeProvider;
let worker = WorkerBuilder::new("http://localhost:3000", "my-token")
.provider(Arc::new(ClaudeCodeProvider::new()))
.concurrency(4)
.poll_interval(Duration::from_secs(2))
.build()?;
worker.run().await?;Implementations§
Source§impl WorkerBuilder
impl WorkerBuilder
Sourcepub fn new(api_url: &str, worker_token: &str) -> Self
pub fn new(api_url: &str, worker_token: &str) -> Self
Create a new builder targeting the given API server.
Sourcepub fn provider(self, provider: Arc<dyn AgentProvider>) -> Self
pub fn provider(self, provider: Arc<dyn AgentProvider>) -> Self
Set the agent provider for AI operations.
Sourcepub fn register(self, handler: impl WorkflowHandler + 'static) -> Self
pub fn register(self, handler: impl WorkflowHandler + 'static) -> Self
Register a workflow handler.
Sourcepub fn concurrency(self, n: usize) -> Self
pub fn concurrency(self, n: usize) -> Self
Set the maximum number of concurrent workflow executions.
Sourcepub fn poll_interval(self, interval: Duration) -> Self
pub fn poll_interval(self, interval: Duration) -> Self
Set the interval between polls for new runs.
Sourcepub fn build(self) -> Result<Worker, WorkerError>
pub fn build(self) -> Result<Worker, WorkerError>
Build the worker.
§Errors
Returns WorkerError::Internal if no provider has been set.
Returns WorkerError::Engine if a handler registration fails.
Auto Trait Implementations§
impl Freeze for WorkerBuilder
impl !RefUnwindSafe for WorkerBuilder
impl Send for WorkerBuilder
impl Sync for WorkerBuilder
impl Unpin for WorkerBuilder
impl UnsafeUnpin for WorkerBuilder
impl !UnwindSafe for WorkerBuilder
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
Mutably borrows from an owned value. Read more