99package dev .restate .sdk .endpoint .definition ;
1010
1111import dev .restate .serde .Serde ;
12+ import java .time .Duration ;
1213import java .util .Collections ;
1314import java .util .HashMap ;
1415import java .util .Map ;
16+ import java .util .Objects ;
1517import java .util .function .Consumer ;
1618import org .jspecify .annotations .Nullable ;
1719
@@ -25,6 +27,13 @@ public final class HandlerDefinition<REQ, RES> {
2527 private final @ Nullable String documentation ;
2628 private final Map <String , String > metadata ;
2729 private final HandlerRunner <REQ , RES > runner ;
30+ private final @ Nullable Duration inactivityTimeout ;
31+ private final @ Nullable Duration abortTimeout ;
32+ private final @ Nullable Duration idempotencyRetention ;
33+ private final @ Nullable Duration workflowRetention ;
34+ private final @ Nullable Duration journalRetention ;
35+ private final @ Nullable Boolean ingressPrivate ;
36+ private final @ Nullable Boolean enableLazyState ;
2837
2938 HandlerDefinition (
3039 String name ,
@@ -34,7 +43,14 @@ public final class HandlerDefinition<REQ, RES> {
3443 Serde <RES > responseSerde ,
3544 @ Nullable String documentation ,
3645 Map <String , String > metadata ,
37- HandlerRunner <REQ , RES > runner ) {
46+ HandlerRunner <REQ , RES > runner ,
47+ @ Nullable Duration inactivityTimeout ,
48+ @ Nullable Duration abortTimeout ,
49+ @ Nullable Duration idempotencyRetention ,
50+ @ Nullable Duration workflowRetention ,
51+ @ Nullable Duration journalRetention ,
52+ @ Nullable Boolean ingressPrivate ,
53+ @ Nullable Boolean enableLazyState ) {
3854 this .name = name ;
3955 this .handlerType = handlerType ;
4056 this .acceptContentType = acceptContentType ;
@@ -43,6 +59,13 @@ public final class HandlerDefinition<REQ, RES> {
4359 this .documentation = documentation ;
4460 this .metadata = metadata ;
4561 this .runner = runner ;
62+ this .inactivityTimeout = inactivityTimeout ;
63+ this .abortTimeout = abortTimeout ;
64+ this .idempotencyRetention = idempotencyRetention ;
65+ this .workflowRetention = workflowRetention ;
66+ this .journalRetention = journalRetention ;
67+ this .ingressPrivate = ingressPrivate ;
68+ this .enableLazyState = enableLazyState ;
4669 }
4770
4871 public String getName () {
@@ -77,6 +100,34 @@ public HandlerRunner<REQ, RES> getRunner() {
77100 return runner ;
78101 }
79102
103+ public @ Nullable Duration getInactivityTimeout () {
104+ return inactivityTimeout ;
105+ }
106+
107+ public @ Nullable Duration getAbortTimeout () {
108+ return abortTimeout ;
109+ }
110+
111+ public @ Nullable Duration getIdempotencyRetention () {
112+ return idempotencyRetention ;
113+ }
114+
115+ public @ Nullable Duration getWorkflowRetention () {
116+ return workflowRetention ;
117+ }
118+
119+ public @ Nullable Duration getJournalRetention () {
120+ return journalRetention ;
121+ }
122+
123+ public @ Nullable Boolean getIngressPrivate () {
124+ return ingressPrivate ;
125+ }
126+
127+ public @ Nullable Boolean getEnableLazyState () {
128+ return enableLazyState ;
129+ }
130+
80131 public HandlerDefinition <REQ , RES > withAcceptContentType (String acceptContentType ) {
81132 return new HandlerDefinition <>(
82133 name ,
@@ -86,7 +137,14 @@ public HandlerDefinition<REQ, RES> withAcceptContentType(String acceptContentTyp
86137 responseSerde ,
87138 documentation ,
88139 metadata ,
89- runner );
140+ runner ,
141+ inactivityTimeout ,
142+ abortTimeout ,
143+ idempotencyRetention ,
144+ workflowRetention ,
145+ journalRetention ,
146+ ingressPrivate ,
147+ enableLazyState );
90148 }
91149
92150 public HandlerDefinition <REQ , RES > withDocumentation (@ Nullable String documentation ) {
@@ -98,7 +156,14 @@ public HandlerDefinition<REQ, RES> withDocumentation(@Nullable String documentat
98156 responseSerde ,
99157 documentation ,
100158 metadata ,
101- runner );
159+ runner ,
160+ inactivityTimeout ,
161+ abortTimeout ,
162+ idempotencyRetention ,
163+ journalRetention ,
164+ workflowRetention ,
165+ ingressPrivate ,
166+ enableLazyState );
102167 }
103168
104169 public HandlerDefinition <REQ , RES > withMetadata (Map <String , String > metadata ) {
@@ -110,13 +175,30 @@ public HandlerDefinition<REQ, RES> withMetadata(Map<String, String> metadata) {
110175 responseSerde ,
111176 documentation ,
112177 metadata ,
113- runner );
178+ runner ,
179+ inactivityTimeout ,
180+ abortTimeout ,
181+ idempotencyRetention ,
182+ workflowRetention ,
183+ journalRetention ,
184+ ingressPrivate ,
185+ enableLazyState );
114186 }
115187
116188 public HandlerDefinition <REQ , RES > configure (
117189 Consumer <HandlerDefinition .Configurator > configurator ) {
118190 HandlerDefinition .Configurator configuratorObj =
119- new HandlerDefinition .Configurator (acceptContentType , documentation , metadata );
191+ new HandlerDefinition .Configurator (
192+ acceptContentType ,
193+ documentation ,
194+ metadata ,
195+ inactivityTimeout ,
196+ abortTimeout ,
197+ idempotencyRetention ,
198+ workflowRetention ,
199+ journalRetention ,
200+ ingressPrivate ,
201+ enableLazyState );
120202 configurator .accept (configuratorObj );
121203
122204 return new HandlerDefinition <>(
@@ -127,22 +209,50 @@ public HandlerDefinition<REQ, RES> configure(
127209 responseSerde ,
128210 configuratorObj .documentation ,
129211 configuratorObj .metadata ,
130- runner );
212+ runner ,
213+ configuratorObj .inactivityTimeout ,
214+ configuratorObj .abortTimeout ,
215+ configuratorObj .idempotencyRetention ,
216+ configuratorObj .workflowRetention ,
217+ configuratorObj .journalRetention ,
218+ configuratorObj .ingressPrivate ,
219+ configuratorObj .enableLazyState );
131220 }
132221
133222 public static final class Configurator {
134223
135224 private @ Nullable String acceptContentType ;
136225 private @ Nullable String documentation ;
137226 private Map <String , String > metadata ;
227+ private @ Nullable Duration inactivityTimeout ;
228+ private @ Nullable Duration abortTimeout ;
229+ private @ Nullable Duration idempotencyRetention ;
230+ private @ Nullable Duration workflowRetention ;
231+ private @ Nullable Duration journalRetention ;
232+ private @ Nullable Boolean ingressPrivate ;
233+ private @ Nullable Boolean enableLazyState ;
138234
139235 public Configurator (
140236 @ Nullable String acceptContentType ,
141237 @ Nullable String documentation ,
142- Map <String , String > metadata ) {
238+ Map <String , String > metadata ,
239+ @ Nullable Duration inactivityTimeout ,
240+ @ Nullable Duration abortTimeout ,
241+ @ Nullable Duration idempotencyRetention ,
242+ @ Nullable Duration workflowRetention ,
243+ @ Nullable Duration journalRetention ,
244+ @ Nullable Boolean ingressPrivate ,
245+ @ Nullable Boolean enableLazyState ) {
143246 this .acceptContentType = acceptContentType ;
144247 this .documentation = documentation ;
145248 this .metadata = new HashMap <>(metadata );
249+ this .inactivityTimeout = inactivityTimeout ;
250+ this .abortTimeout = abortTimeout ;
251+ this .idempotencyRetention = idempotencyRetention ;
252+ this .workflowRetention = workflowRetention ;
253+ this .journalRetention = journalRetention ;
254+ this .ingressPrivate = ingressPrivate ;
255+ this .enableLazyState = enableLazyState ;
146256 }
147257
148258 public @ Nullable String getAcceptContentType () {
@@ -188,6 +298,97 @@ public Configurator metadata(Map<String, String> metadata) {
188298 this .setMetadata (metadata );
189299 return this ;
190300 }
301+
302+ public @ Nullable Duration getInactivityTimeout () {
303+ return inactivityTimeout ;
304+ }
305+
306+ public void setInactivityTimeout (@ Nullable Duration inactivityTimeout ) {
307+ this .inactivityTimeout = inactivityTimeout ;
308+ }
309+
310+ public Configurator inactivityTimeout (@ Nullable Duration inactivityTimeout ) {
311+ setInactivityTimeout (inactivityTimeout );
312+ return this ;
313+ }
314+
315+ public @ Nullable Duration getAbortTimeout () {
316+ return abortTimeout ;
317+ }
318+
319+ public void setAbortTimeout (@ Nullable Duration abortTimeout ) {
320+ this .abortTimeout = abortTimeout ;
321+ }
322+
323+ public Configurator abortTimeout (@ Nullable Duration abortTimeout ) {
324+ setAbortTimeout (abortTimeout );
325+ return this ;
326+ }
327+
328+ public @ Nullable Duration getIdempotencyRetention () {
329+ return idempotencyRetention ;
330+ }
331+
332+ public void setIdempotencyRetention (@ Nullable Duration idempotencyRetention ) {
333+ this .idempotencyRetention = idempotencyRetention ;
334+ }
335+
336+ public Configurator idempotencyRetention (@ Nullable Duration idempotencyRetention ) {
337+ setIdempotencyRetention (idempotencyRetention );
338+ return this ;
339+ }
340+
341+ public @ Nullable Duration getWorkflowRetention () {
342+ return workflowRetention ;
343+ }
344+
345+ public void setWorkflowRetention (@ Nullable Duration workflowRetention ) {
346+ this .workflowRetention = workflowRetention ;
347+ }
348+
349+ public Configurator workflowRetention (@ Nullable Duration workflowRetention ) {
350+ setWorkflowRetention (workflowRetention );
351+ return this ;
352+ }
353+
354+ public @ Nullable Duration getJournalRetention () {
355+ return journalRetention ;
356+ }
357+
358+ public void setJournalRetention (@ Nullable Duration journalRetention ) {
359+ this .journalRetention = journalRetention ;
360+ }
361+
362+ public Configurator journalRetention (@ Nullable Duration journalRetention ) {
363+ setJournalRetention (journalRetention );
364+ return this ;
365+ }
366+
367+ public @ Nullable Boolean getIngressPrivate () {
368+ return ingressPrivate ;
369+ }
370+
371+ public void setIngressPrivate (@ Nullable Boolean ingressPrivate ) {
372+ this .ingressPrivate = ingressPrivate ;
373+ }
374+
375+ public Configurator ingressPrivate (@ Nullable Boolean ingressPrivate ) {
376+ setIngressPrivate (ingressPrivate );
377+ return this ;
378+ }
379+
380+ public @ Nullable Boolean getEnableLazyState () {
381+ return enableLazyState ;
382+ }
383+
384+ public void setEnableLazyState (@ Nullable Boolean enableLazyState ) {
385+ this .enableLazyState = enableLazyState ;
386+ }
387+
388+ public Configurator enableLazyState (@ Nullable Boolean enableLazyState ) {
389+ setEnableLazyState (enableLazyState );
390+ return this ;
391+ }
191392 }
192393
193394 public static <REQ , RES > HandlerDefinition <REQ , RES > of (
@@ -204,6 +405,53 @@ public static <REQ, RES> HandlerDefinition<REQ, RES> of(
204405 responseSerde ,
205406 null ,
206407 Collections .emptyMap (),
207- runner );
408+ runner ,
409+ null ,
410+ null ,
411+ null ,
412+ null ,
413+ null ,
414+ null ,
415+ null );
416+ }
417+
418+ @ Override
419+ public boolean equals (Object o ) {
420+ if (!(o instanceof HandlerDefinition <?, ?> that )) return false ;
421+ return Objects .equals (getName (), that .getName ())
422+ && getHandlerType () == that .getHandlerType ()
423+ && Objects .equals (getAcceptContentType (), that .getAcceptContentType ())
424+ && Objects .equals (getRequestSerde (), that .getRequestSerde ())
425+ && Objects .equals (getResponseSerde (), that .getResponseSerde ())
426+ && Objects .equals (getDocumentation (), that .getDocumentation ())
427+ && Objects .equals (getMetadata (), that .getMetadata ())
428+ && Objects .equals (getRunner (), that .getRunner ())
429+ && Objects .equals (getInactivityTimeout (), that .getInactivityTimeout ())
430+ && Objects .equals (getAbortTimeout (), that .getAbortTimeout ())
431+ && Objects .equals (getIdempotencyRetention (), that .getIdempotencyRetention ())
432+ && Objects .equals (getWorkflowRetention (), that .getWorkflowRetention ())
433+ && Objects .equals (getJournalRetention (), that .getJournalRetention ())
434+ && Objects .equals (getIngressPrivate (), that .getIngressPrivate ())
435+ && Objects .equals (getEnableLazyState (), that .getEnableLazyState ());
436+ }
437+
438+ @ Override
439+ public int hashCode () {
440+ return Objects .hash (
441+ getName (),
442+ getHandlerType (),
443+ getAcceptContentType (),
444+ getRequestSerde (),
445+ getResponseSerde (),
446+ getDocumentation (),
447+ getMetadata (),
448+ getRunner (),
449+ getInactivityTimeout (),
450+ getAbortTimeout (),
451+ getIdempotencyRetention (),
452+ getWorkflowRetention (),
453+ getJournalRetention (),
454+ getIngressPrivate (),
455+ getEnableLazyState ());
208456 }
209457}
0 commit comments