couchbase_core/options/
waituntilready.rs1use crate::httpx::request::OnBehalfOfInfo;
20use crate::retry::{RetryStrategy, DEFAULT_RETRY_STRATEGY};
21use crate::service_type::ServiceType;
22use std::sync::Arc;
23
24#[derive(Copy, Debug, Default, Clone, Eq, PartialEq)]
25pub enum ClusterState {
26 #[default]
27 Online,
28 Degraded,
29 Offline,
30}
31
32#[derive(Debug, Clone)]
33#[non_exhaustive]
34pub struct WaitUntilReadyOptions {
35 pub desired_state: Option<ClusterState>,
36 pub service_types: Option<Vec<ServiceType>>,
37 pub retry_strategy: Arc<dyn RetryStrategy>,
38
39 pub on_behalf_of: Option<OnBehalfOfInfo>,
40}
41
42impl Default for WaitUntilReadyOptions {
43 fn default() -> Self {
44 Self::new()
45 }
46}
47
48impl WaitUntilReadyOptions {
49 pub fn new() -> Self {
50 Self {
51 desired_state: None,
52 service_types: None,
53 retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
54 on_behalf_of: None,
55 }
56 }
57
58 pub fn desired_state(mut self, state: ClusterState) -> Self {
59 self.desired_state = Some(state);
60 self
61 }
62
63 pub fn service_types(mut self, service_types: Vec<ServiceType>) -> Self {
64 self.service_types = Some(service_types);
65 self
66 }
67
68 pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
69 self.retry_strategy = retry_strategy;
70 self
71 }
72
73 pub fn on_behalf_of(mut self, info: OnBehalfOfInfo) -> Self {
74 self.on_behalf_of = Some(info);
75 self
76 }
77}