@@ -16,6 +16,12 @@ pub struct ServiceOptions {
1616 pub ( crate ) journal_retention : Option < Duration > ,
1717 pub ( crate ) enable_lazy_state : Option < bool > ,
1818 pub ( crate ) ingress_private : Option < bool > ,
19+ // Retry policy options
20+ pub ( crate ) retry_policy_initial_interval : Option < Duration > ,
21+ pub ( crate ) retry_policy_exponentiation_factor : Option < f64 > ,
22+ pub ( crate ) retry_policy_max_interval : Option < Duration > ,
23+ pub ( crate ) retry_policy_max_attempts : Option < u64 > ,
24+ pub ( crate ) retry_policy_on_max_attempts : Option < crate :: discovery:: RetryPolicyOnMaxAttempts > ,
1925 pub ( crate ) handler_options : HashMap < String , HandlerOptions > ,
2026
2127 _priv : ( ) ,
@@ -89,6 +95,53 @@ impl ServiceOptions {
8995 self
9096 }
9197
98+ /// Initial delay before the first retry attempt.
99+ ///
100+ /// If unset, the server default is used.
101+ pub fn retry_policy_initial_interval ( mut self , interval : Duration ) -> Self {
102+ self . retry_policy_initial_interval = Some ( interval) ;
103+ self
104+ }
105+
106+ /// Exponential backoff multiplier used to compute the next retry delay.
107+ ///
108+ /// For attempt n, the next delay is roughly previousDelay * exponentiationFactor,
109+ /// capped by retry_policy_max_interval if set.
110+ pub fn retry_policy_exponentiation_factor ( mut self , factor : f64 ) -> Self {
111+ self . retry_policy_exponentiation_factor = Some ( factor) ;
112+ self
113+ }
114+
115+ /// Upper bound for the computed retry delay.
116+ pub fn retry_policy_max_interval ( mut self , interval : Duration ) -> Self {
117+ self . retry_policy_max_interval = Some ( interval) ;
118+ self
119+ }
120+
121+ /// Maximum number of attempts before giving up retrying.
122+ ///
123+ /// The initial call counts as the first attempt; retries increment the count by 1.
124+ pub fn retry_policy_max_attempts ( mut self , attempts : u64 ) -> Self {
125+ self . retry_policy_max_attempts = Some ( attempts) ;
126+ self
127+ }
128+
129+ /// Behavior when the configured retry_policy_max_attempts is reached: pause the invocation.
130+ ///
131+ /// The invocation enters the paused state and can be manually resumed from the CLI or UI.
132+ pub fn retry_policy_pause_on_max_attempts ( mut self ) -> Self {
133+ self . retry_policy_on_max_attempts = Some ( crate :: discovery:: RetryPolicyOnMaxAttempts :: Pause ) ;
134+ self
135+ }
136+
137+ /// Behavior when the configured retry_policy_max_attempts is reached: kill the invocation.
138+ ///
139+ /// The invocation will be marked as failed and will not be retried unless explicitly re-triggered.
140+ pub fn retry_policy_kill_on_max_attempts ( mut self ) -> Self {
141+ self . retry_policy_on_max_attempts = Some ( crate :: discovery:: RetryPolicyOnMaxAttempts :: Kill ) ;
142+ self
143+ }
144+
92145 /// Handler-specific options.
93146 ///
94147 /// *Note*: If you provide a handler name for a non-existing handler, binding the service will *panic!*.
@@ -109,6 +162,12 @@ pub struct HandlerOptions {
109162 pub ( crate ) journal_retention : Option < Duration > ,
110163 pub ( crate ) ingress_private : Option < bool > ,
111164 pub ( crate ) enable_lazy_state : Option < bool > ,
165+ // Retry policy options
166+ pub ( crate ) retry_policy_initial_interval : Option < Duration > ,
167+ pub ( crate ) retry_policy_exponentiation_factor : Option < f64 > ,
168+ pub ( crate ) retry_policy_max_interval : Option < Duration > ,
169+ pub ( crate ) retry_policy_max_attempts : Option < u64 > ,
170+ pub ( crate ) retry_policy_on_max_attempts : Option < crate :: discovery:: RetryPolicyOnMaxAttempts > ,
112171
113172 _priv : ( ) ,
114173}
@@ -183,6 +242,53 @@ impl HandlerOptions {
183242 self . enable_lazy_state = Some ( enable) ;
184243 self
185244 }
245+
246+ /// Initial delay before the first retry attempt.
247+ ///
248+ /// If unset, the server default is used.
249+ pub fn retry_policy_initial_interval ( mut self , interval : Duration ) -> Self {
250+ self . retry_policy_initial_interval = Some ( interval) ;
251+ self
252+ }
253+
254+ /// Exponential backoff multiplier used to compute the next retry delay.
255+ ///
256+ /// For attempt n, the next delay is roughly previousDelay * exponentiationFactor,
257+ /// capped by retry_policy_max_interval if set.
258+ pub fn retry_policy_exponentiation_factor ( mut self , factor : f64 ) -> Self {
259+ self . retry_policy_exponentiation_factor = Some ( factor) ;
260+ self
261+ }
262+
263+ /// Upper bound for the computed retry delay.
264+ pub fn retry_policy_max_interval ( mut self , interval : Duration ) -> Self {
265+ self . retry_policy_max_interval = Some ( interval) ;
266+ self
267+ }
268+
269+ /// Maximum number of attempts before giving up retrying.
270+ ///
271+ /// The initial call counts as the first attempt; retries increment the count by 1.
272+ pub fn retry_policy_max_attempts ( mut self , attempts : u64 ) -> Self {
273+ self . retry_policy_max_attempts = Some ( attempts) ;
274+ self
275+ }
276+
277+ /// Behavior when the configured retry_policy_max_attempts is reached: pause the invocation.
278+ ///
279+ /// The invocation enters the paused state and can be manually resumed from the CLI or UI.
280+ pub fn retry_policy_pause_on_max_attempts ( mut self ) -> Self {
281+ self . retry_policy_on_max_attempts = Some ( crate :: discovery:: RetryPolicyOnMaxAttempts :: Pause ) ;
282+ self
283+ }
284+
285+ /// Behavior when the configured retry_policy_max_attempts is reached: kill the invocation.
286+ ///
287+ /// The invocation will be marked as failed and will not be retried unless explicitly re-triggered.
288+ pub fn retry_policy_kill_on_max_attempts ( mut self ) -> Self {
289+ self . retry_policy_on_max_attempts = Some ( crate :: discovery:: RetryPolicyOnMaxAttempts :: Kill ) ;
290+ self
291+ }
186292}
187293
188294/// Builder for [`Endpoint`]
0 commit comments