Skip to main content

dex_sdk/
flow_config.rs

1// Copyright (c) 2026 Super Durable, Inc.
2//
3// Licensed under the Super Durable Source License 1.0.
4// You may not use this file except in compliance with the License.
5// See the LICENSE file in the repository root.
6//
7// SPDX-License-Identifier: LicenseRef-Super-Durable-1.0
8
9use crate::{StepDurability, WorkerTarget};
10
11#[derive(Clone, Debug, Default)]
12/// Overrides runtime behavior for one Flow.
13///
14/// Omitted fields use Dex server defaults. Pass a value to [`crate::StartFlowOptions::config_override`]
15/// for one execution or to [`crate::Client::update_flow_config`] for an active Flow.
16pub struct FlowConfig {
17    pub(crate) active_step_search_mode: Option<ActiveStepSearchMode>,
18    pub(crate) attribute_store_names: Option<Vec<String>>,
19    pub(crate) continue_as_new_threshold: Option<u32>,
20    pub(crate) continue_as_new_page_size_bytes: Option<u32>,
21    pub(crate) step_durability: Option<StepDurability>,
22    pub(crate) worker_target: Option<WorkerTarget>,
23}
24
25impl FlowConfig {
26    /// Creates a config with every field delegated to server defaults.
27    pub fn new() -> Self {
28        Self::default()
29    }
30
31    /// Controls which active Step types Dex places in the search index.
32    pub fn active_step_search_mode(mut self, value: ActiveStepSearchMode) -> Self {
33        self.active_step_search_mode = Some(value);
34        self
35    }
36
37    /// Selects server-configured Attribute Stores for opted-in Attribute writes.
38    ///
39    /// Omitting this builder preserves the existing Flow setting. Passing an empty vector retains
40    /// protocol presence and disables later synchronization. Each enabled Attribute write is
41    /// projected to every selected store; an external store failure does not roll back the Flow
42    /// Attribute write.
43    #[must_use]
44    pub fn attribute_store_names(mut self, values: Vec<String>) -> Self {
45        self.attribute_store_names = Some(values);
46        self
47    }
48
49    /// Sets the event-count threshold that triggers Continue-As-New.
50    pub fn continue_as_new_threshold(mut self, value: u32) -> Self {
51        self.continue_as_new_threshold = Some(value);
52        self
53    }
54
55    /// Sets the maximum history page size, in bytes, carried into Continue-As-New.
56    pub fn continue_as_new_page_size_bytes(mut self, value: u32) -> Self {
57        self.continue_as_new_page_size_bytes = Some(value);
58        self
59    }
60
61    /// Sets the default persistence durability for Step handler writes.
62    pub fn step_durability(mut self, value: StepDurability) -> Self {
63        self.step_durability = Some(value);
64        self
65    }
66
67    /// Routes future Step and RPC invocations to this WorkerService target.
68    pub fn worker_target(mut self, value: WorkerTarget) -> Self {
69        self.worker_target = Some(value);
70        self
71    }
72}
73
74#[derive(Clone, Copy, Debug, Eq, PartialEq)]
75/// Controls which active Step types Dex indexes for Flow search.
76pub enum ActiveStepSearchMode {
77    /// Indexes every active Step type, including execute-only Steps.
78    All,
79    /// Indexes a Step type only after its `wait_for` handler runs.
80    WithWaitFor,
81    /// Disables active-Step indexing for the Flow.
82    Disabled,
83}