Skip to main content

dex_sdk/
client_options.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::WorkerTarget;
10
11#[derive(Clone, Debug)]
12/// Configures how a [`crate::Client`] reaches Dex and identifies application workers.
13///
14/// [`ClientOptions::new`] connects to `127.0.0.1:8801` over plaintext gRPC and supplies no default
15/// worker target. A per-Flow [`crate::FlowConfig`] can override the target.
16pub struct ClientOptions {
17    server_address: String,
18    worker_target: Option<WorkerTarget>,
19}
20
21impl ClientOptions {
22    /// Creates options with the local Dex server default and no worker target.
23    pub fn new() -> Self {
24        Self {
25            server_address: "127.0.0.1:8801".to_string(),
26            worker_target: None,
27        }
28    }
29
30    /// Sets the plaintext gRPC `host:port` used for every client request.
31    pub fn server_address(mut self, value: impl Into<String>) -> Self {
32        self.server_address = value.into();
33        self
34    }
35
36    /// Sets the WorkerService target advertised by newly started Flows.
37    pub fn worker_target(mut self, value: WorkerTarget) -> Self {
38        self.worker_target = Some(value);
39        self
40    }
41
42    pub(crate) fn server_address_value(&self) -> &str {
43        &self.server_address
44    }
45
46    pub(crate) fn worker_target_value(&self) -> Option<&WorkerTarget> {
47        self.worker_target.as_ref()
48    }
49}
50
51impl Default for ClientOptions {
52    fn default() -> Self {
53        Self::new()
54    }
55}