11package io .eigr .spawn .api ;
22
3- import lombok .AllArgsConstructor ;
4- import lombok .Builder ;
5- import lombok .Getter ;
6- import lombok .NoArgsConstructor ;
7-
83import java .time .Duration ;
94import java .time .LocalDateTime ;
105import java .time .temporal .ChronoUnit ;
116import java .util .Optional ;
127
13- @ Builder
14- @ Getter
15- @ AllArgsConstructor
16- @ NoArgsConstructor
178public class InvocationOpts {
189
19- @ Builder .Default
20- private boolean async = false ;
10+ private final boolean async ;
11+ private final Duration timeoutSeconds ;
12+ private final Optional <Long > delaySeconds ;
13+ private final Optional <LocalDateTime > scheduledTo ;
14+
15+ private InvocationOpts (InvocationOptsBuilder invocationOptsBuilder ) {
16+ this .async = invocationOptsBuilder .async ;
17+ this .timeoutSeconds = invocationOptsBuilder .timeoutSeconds ;
18+ this .delaySeconds = invocationOptsBuilder .delaySeconds ;
19+ this .scheduledTo = invocationOptsBuilder .scheduledTo ;
20+ }
21+
22+ public static InvocationOptsBuilder builder () {
23+ return new InvocationOptsBuilder ();
24+ }
25+
26+ public boolean isAsync () {
27+ return async ;
28+ }
2129
22- @ Builder .Default
23- private Duration timeoutSeconds = Duration .ofSeconds (10 );
30+ public Duration getTimeoutSeconds () {
31+ return timeoutSeconds ;
32+ }
2433
25- @ Builder .Default
26- private Optional <Long > delaySeconds = Optional .empty ();
34+ public Optional <Long > getDelaySeconds () {
35+ return delaySeconds ;
36+ }
2737
28- @ Builder .Default
29- private Optional <LocalDateTime > scheduledTo = Optional .empty ();
38+ public Optional <LocalDateTime > getScheduledTo () {
39+ return scheduledTo ;
40+ }
3041
3142 public long getScheduleTimeInLong () {
3243 if (scheduledTo .isPresent ()) {
@@ -40,4 +51,36 @@ public long getScheduleTimeInLong() {
4051 public long getTimeout () {
4152 return this .timeoutSeconds .toMillis ();
4253 }
54+
55+ public static final class InvocationOptsBuilder {
56+
57+ private boolean async = false ;
58+ private Duration timeoutSeconds = Duration .ofSeconds (10 );
59+ private Optional <Long > delaySeconds = Optional .empty ();
60+ private Optional <LocalDateTime > scheduledTo = Optional .empty ();
61+
62+ public InvocationOpts build () {
63+ return new InvocationOpts (this );
64+ }
65+
66+ public InvocationOptsBuilder async (boolean async ) {
67+ this .async = async ;
68+ return this ;
69+ }
70+
71+ public InvocationOptsBuilder timeoutSeconds (Duration timeoutSeconds ) {
72+ this .timeoutSeconds = timeoutSeconds ;
73+ return this ;
74+ }
75+
76+ public InvocationOptsBuilder delaySeconds (Optional <Long > delaySeconds ) {
77+ this .delaySeconds = delaySeconds ;
78+ return this ;
79+ }
80+
81+ public InvocationOptsBuilder scheduledTo (Optional <LocalDateTime > scheduledTo ) {
82+ this .scheduledTo = scheduledTo ;
83+ return this ;
84+ }
85+ }
4386}
0 commit comments