Skip to main content

nominal_api/conjure/objects/persistent/compute/api/
subscription_options.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    PartialEq,
7    Eq,
8    PartialOrd,
9    Ord,
10    Hash
11)]
12#[serde(crate = "conjure_object::serde")]
13#[conjure_object::private::staged_builder::staged_builder]
14#[builder(crate = conjure_object::private::staged_builder, update, inline)]
15pub struct SubscriptionOptions {
16    #[serde(rename = "minDelay")]
17    min_delay: super::Milliseconds,
18    #[builder(default, into)]
19    #[serde(rename = "allowAppends", skip_serializing_if = "Option::is_none", default)]
20    allow_appends: Option<bool>,
21    #[builder(
22        default,
23        custom(
24            type = impl
25            Into<Option<super::ResultConfiguration>>,
26            convert = |v|v.into().map(Box::new)
27        )
28    )]
29    #[serde(
30        rename = "resultConfiguration",
31        skip_serializing_if = "Option::is_none",
32        default
33    )]
34    result_configuration: Option<Box<super::ResultConfiguration>>,
35    #[builder(default, into)]
36    #[serde(rename = "useFlink", skip_serializing_if = "Option::is_none", default)]
37    use_flink: Option<bool>,
38    #[builder(
39        default,
40        custom(
41            type = impl
42            Into<Option<super::super::super::super::scout::run::api::Duration>>,
43            convert = |v|v.into().map(Box::new)
44        )
45    )]
46    #[serde(
47        rename = "allowedLateness",
48        skip_serializing_if = "Option::is_none",
49        default
50    )]
51    allowed_lateness: Option<Box<super::super::super::super::scout::run::api::Duration>>,
52}
53impl SubscriptionOptions {
54    /// Constructs a new instance of the type.
55    #[inline]
56    pub fn new(min_delay: super::Milliseconds) -> Self {
57        Self::builder().min_delay(min_delay).build()
58    }
59    /// The minimum delay between `SubscriptionUpdate`s sent for this subscription.
60    #[inline]
61    pub fn min_delay(&self) -> super::Milliseconds {
62        self.min_delay
63    }
64    /// Can be set to `false` by the client to indicate that it doesn't support appends for this subscription
65    /// and always wants to receive full results. Defaults to `false` if not set.
66    /// The expectation is that clients should implement support for appends for any of the results covered in
67    /// `ComputeNodeAppendResponse` and set this to `true` as quickly as possible. However, in order to support
68    /// adding new sub-types to `ComputeNodeAppendResponse` without breaking clients that haven't upgraded yet
69    /// and haven't yet added support for them, we default this to `false` and make clients opt-in as soon as they
70    /// implement support.
71    #[deprecated(note = "Use `resultConfiguration` instead.\n")]
72    #[inline]
73    pub fn allow_appends(&self) -> Option<bool> {
74        self.allow_appends.as_ref().map(|o| *o)
75    }
76    /// Defines the results that are sent for this subscription. If not set, falls back to the behavior
77    /// defined by `allowAppends`.
78    #[inline]
79    pub fn result_configuration(&self) -> Option<&super::ResultConfiguration> {
80        self.result_configuration.as_ref().map(|o| &**o)
81    }
82    /// If true and server has Flink enabled, use Flink-based streaming computation.
83    /// Defaults to false if not specified.
84    #[inline]
85    pub fn use_flink(&self) -> Option<bool> {
86        self.use_flink.as_ref().map(|o| *o)
87    }
88    /// Configures the lateness threshold for the raw points.
89    /// Results will be delayed by the duration specified by this setting.
90    /// Note this configuration is only available if we are using Flink.
91    /// Defaults to 1 second.
92    #[inline]
93    pub fn allowed_lateness(
94        &self,
95    ) -> Option<&super::super::super::super::scout::run::api::Duration> {
96        self.allowed_lateness.as_ref().map(|o| &**o)
97    }
98}