dex_sdk/
worker_options.rs1use std::time::Duration;
10
11#[derive(Clone, Debug)]
12pub struct WorkerTarget {
17 address: String,
18 headless: bool,
19}
20
21impl WorkerTarget {
22 pub fn new(address: impl Into<String>) -> Self {
24 Self {
25 address: address.into(),
26 headless: false,
27 }
28 }
29
30 pub fn headless(mut self, value: bool) -> Self {
32 self.headless = value;
33 self
34 }
35
36 pub fn address(&self) -> &str {
38 &self.address
39 }
40
41 pub fn is_headless(&self) -> bool {
43 self.headless
44 }
45}
46
47#[derive(Clone, Debug)]
48pub struct WorkerOptions {
53 bind_address: String,
54 server_address: String,
55 worker_target: Option<WorkerTarget>,
56 attribute_index_sync_timeout: Duration,
57}
58
59impl WorkerOptions {
60 pub fn new() -> Self {
62 Self {
63 bind_address: "0.0.0.0:8803".to_string(),
64 server_address: "127.0.0.1:8801".to_string(),
65 worker_target: None,
66 attribute_index_sync_timeout: Duration::from_secs(120),
67 }
68 }
69
70 pub fn bind_address(mut self, value: impl Into<String>) -> Self {
72 self.bind_address = value.into();
73 self
74 }
75
76 pub fn server_address(mut self, value: impl Into<String>) -> Self {
78 self.server_address = value.into();
79 self
80 }
81
82 pub fn worker_target(mut self, value: WorkerTarget) -> Self {
84 self.worker_target = Some(value);
85 self
86 }
87
88 pub fn attribute_index_sync_timeout(mut self, value: Duration) -> Self {
93 self.attribute_index_sync_timeout = value;
94 self
95 }
96
97 pub(crate) fn bind_address_value(&self) -> &str {
98 &self.bind_address
99 }
100
101 pub(crate) fn server_address_value(&self) -> &str {
102 &self.server_address
103 }
104
105 pub(crate) fn worker_target_value(&self) -> Option<&WorkerTarget> {
106 self.worker_target.as_ref()
107 }
108
109 pub(crate) fn attribute_index_sync_timeout_value(&self) -> Duration {
110 self.attribute_index_sync_timeout
111 }
112}
113
114impl Default for WorkerOptions {
115 fn default() -> Self {
116 Self::new()
117 }
118}