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_name: Option<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 the server-configured Attribute Store for opted-in Attribute writes.
38 ///
39 /// Omitting this builder preserves the existing Flow setting. Passing an empty string retains
40 /// protocol presence and disables later synchronization. Projection is asynchronous, and an
41 /// external store failure does not roll back the Flow Attribute write.
42 #[must_use]
43 pub fn attribute_store_name(mut self, value: impl Into<String>) -> Self {
44 self.attribute_store_name = Some(value.into());
45 self
46 }
47
48 /// Sets the event-count threshold that triggers Continue-As-New.
49 pub fn continue_as_new_threshold(mut self, value: u32) -> Self {
50 self.continue_as_new_threshold = Some(value);
51 self
52 }
53
54 /// Sets the maximum history page size, in bytes, carried into Continue-As-New.
55 pub fn continue_as_new_page_size_bytes(mut self, value: u32) -> Self {
56 self.continue_as_new_page_size_bytes = Some(value);
57 self
58 }
59
60 /// Sets the default persistence durability for Step handler writes.
61 pub fn step_durability(mut self, value: StepDurability) -> Self {
62 self.step_durability = Some(value);
63 self
64 }
65
66 /// Routes future Step and RPC invocations to this WorkerService target.
67 pub fn worker_target(mut self, value: WorkerTarget) -> Self {
68 self.worker_target = Some(value);
69 self
70 }
71}
72
73#[derive(Clone, Copy, Debug, Eq, PartialEq)]
74/// Controls which active Step types Dex indexes for Flow search.
75pub enum ActiveStepSearchMode {
76 /// Indexes every active Step type, including execute-only Steps.
77 All,
78 /// Indexes a Step type only after its `wait_for` handler runs.
79 WithWaitFor,
80 /// Disables active-Step indexing for the Flow.
81 Disabled,
82}