dex_sdk/flow_config.rs
1// Copyright (c) 2026 Super Durable, Inc.
2//
3// Licensed under the Sustainable Use 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-Sustainable-Use-1.0
8
9use crate::StepDurability;
10
11#[derive(Clone, Debug, Default)]
12/// Overrides runtime behavior for one Flow.
13///
14/// StartFlow and SubFlow always select pull Workers, even when no override is supplied.
15/// [`crate::Client::update_flow_config`] leaves the Worker target unset, preserving the active Flow
16/// target. Other omitted fields use server defaults for StartFlow, inherit the parent configuration
17/// for SubFlow, and retain the active Flow setting for updates.
18/// Pass a value to [`crate::StartFlowOptions::config_override`] for one execution or to
19/// [`crate::Client::update_flow_config`] for an active Flow.
20pub struct FlowConfig {
21 pub(crate) active_step_search_mode: Option<ActiveStepSearchMode>,
22 pub(crate) attribute_store_names: Option<Vec<String>>,
23 pub(crate) continue_as_new_threshold: Option<u32>,
24 pub(crate) continue_as_new_page_size_bytes: Option<u32>,
25 pub(crate) step_durability: Option<StepDurability>,
26}
27
28impl FlowConfig {
29 /// Creates a config with no overrides.
30 pub fn new() -> Self {
31 Self::default()
32 }
33
34 /// Controls which active Step types Dex places in the search index.
35 pub fn active_step_search_mode(mut self, value: ActiveStepSearchMode) -> Self {
36 self.active_step_search_mode = Some(value);
37 self
38 }
39
40 /// Selects server-configured Attribute Stores for opted-in Attribute writes.
41 ///
42 /// Omitting this builder preserves the existing Flow setting. Passing an empty vector retains
43 /// protocol presence and disables later synchronization. Each enabled Attribute write is
44 /// projected to every selected store; an external store failure does not roll back the Flow
45 /// Attribute write.
46 #[must_use]
47 pub fn attribute_store_names(mut self, values: Vec<String>) -> Self {
48 self.attribute_store_names = Some(values);
49 self
50 }
51
52 /// Sets the event-count threshold that triggers Continue-As-New.
53 pub fn continue_as_new_threshold(mut self, value: u32) -> Self {
54 self.continue_as_new_threshold = Some(value);
55 self
56 }
57
58 /// Sets the maximum history page size, in bytes, carried into Continue-As-New.
59 pub fn continue_as_new_page_size_bytes(mut self, value: u32) -> Self {
60 self.continue_as_new_page_size_bytes = Some(value);
61 self
62 }
63
64 /// Sets the default persistence durability for Step handler writes.
65 pub fn step_durability(mut self, value: StepDurability) -> Self {
66 self.step_durability = Some(value);
67 self
68 }
69}
70
71#[derive(Clone, Copy, Debug, Eq, PartialEq)]
72/// Controls which active Step types Dex indexes for Flow search.
73pub enum ActiveStepSearchMode {
74 /// Indexes every active Step type, including execute-only Steps.
75 All,
76 /// Indexes a Step type only after its `wait_for` handler runs.
77 WithWaitFor,
78 /// Disables active-Step indexing for the Flow.
79 Disabled,
80}