pub struct Cluster { /* private fields */ }Expand description
Main cluster handle
Implementations§
Source§impl Cluster
impl Cluster
Sourcepub fn builder() -> ClusterBuilder
pub fn builder() -> ClusterBuilder
Create a new cluster builder
Sourcepub async fn connect<I, S>(seeds: I) -> Result<Cluster, PolarisError>
pub async fn connect<I, S>(seeds: I) -> Result<Cluster, PolarisError>
Connect to an existing cluster
§Example
let cluster = Cluster::connect(["10.0.0.1:7001", "10.0.0.2:7001"]).await?;Sourcepub async fn submit(&self, task: Task) -> Result<TaskHandle, PolarisError>
pub async fn submit(&self, task: Task) -> Result<TaskHandle, PolarisError>
Submit a task to the cluster
§Example
let task = Task::new("my_task", Bytes::from("payload"));
let handle = cluster.submit(task).await?;
let result = handle.result().await?;Sourcepub async fn submit_batch(
&self,
tasks: Vec<Task>,
) -> Result<Vec<TaskHandle>, PolarisError>
pub async fn submit_batch( &self, tasks: Vec<Task>, ) -> Result<Vec<TaskHandle>, PolarisError>
Submit multiple tasks and collect results
§Example
let tasks = vec![
Task::new("task1", Bytes::from("input1")),
Task::new("task2", Bytes::from("input2")),
];
let results = cluster.submit_batch(tasks).await?;Sourcepub fn map<T, I>(&self, tasks: I) -> MapBuilder<T>where
I: IntoIterator<Item = Task>,
pub fn map<T, I>(&self, tasks: I) -> MapBuilder<T>where
I: IntoIterator<Item = Task>,
Map over a list of tasks
Submit multiple tasks and collect their results in parallel.
§Example
let tasks = vec![
Task::new("task1", Bytes::from("input1")),
Task::new("task2", Bytes::from("input2")),
];
let results = cluster.map(tasks)
.with_retry(5)
.await_impl()
.await?;Sourcepub fn task_status(&self, task_id: TaskId) -> Option<TaskStatus>
pub fn task_status(&self, task_id: TaskId) -> Option<TaskStatus>
Get task status
Sourcepub fn stats(&self) -> ClusterStats
pub fn stats(&self) -> ClusterStats
Get cluster statistics
Sourcepub async fn shutdown(&self) -> Result<(), PolarisError>
pub async fn shutdown(&self) -> Result<(), PolarisError>
Shutdown the cluster gracefully
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Cluster
impl !RefUnwindSafe for Cluster
impl Send for Cluster
impl Sync for Cluster
impl Unpin for Cluster
impl !UnwindSafe for Cluster
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