@@ -26,8 +26,8 @@ class JobBuilder
2626 public static function fromService (string $ serviceId , array $ serviceArgs = []) : self
2727 {
2828 $ self = new self ();
29- $ self ->payload [' service ' ] = $ serviceId ;
30- $ self ->payload [' args ' ] = $ serviceArgs ;
29+ $ self ->payload [JobOptions:: PAYLOAD_SERVICE_ID ] = $ serviceId ;
30+ $ self ->payload [JobOptions:: PAYLOAD_SERVICE_ARGS ] = $ serviceArgs ;
3131
3232 return $ self ;
3333 }
@@ -45,48 +45,64 @@ public function withServiceArg($value, $key = null) : self
4545 $ new = clone $ this ;
4646
4747 (null === $ key )
48- ? $ new ->payload [' args ' ][] = $ value
49- : $ new ->payload [' args ' ][$ key ] = $ value ;
48+ ? $ new ->payload [JobOptions:: PAYLOAD_SERVICE_ARGS ][] = $ value
49+ : $ new ->payload [JobOptions:: PAYLOAD_SERVICE_ARGS ][$ key ] = $ value ;
5050
5151 return $ new ;
5252 }
5353
5454 public function withConstantBackoff () : self
5555 {
5656 $ new = clone $ this ;
57- $ new ->jobOptions [' retry_strategy ' ] = ' constant ' ;
57+ $ new ->jobOptions [JobOptions:: RETRY_STRATEGY ] = RetryStrategies:: CONSTANT ;
5858
5959 return $ new ;
6060 }
6161
6262 public function withExponentialBackoff () : self
6363 {
6464 $ new = clone $ this ;
65- $ new ->jobOptions [' retry_strategy ' ] = ' exponential ' ;
65+ $ new ->jobOptions [JobOptions:: RETRY_STRATEGY ] = RetryStrategies:: EXPONENTIAL ;
6666
6767 return $ new ;
6868 }
6969
7070 public function withLinearBackoff () : self
7171 {
7272 $ new = clone $ this ;
73- $ new ->jobOptions [' retry_strategy ' ] = ' linear ' ;
73+ $ new ->jobOptions [JobOptions:: RETRY_STRATEGY ] = RetryStrategies:: LINEAR ;
7474
7575 return $ new ;
7676 }
7777
7878 public function withMaxRetries (int $ maxRetries ) : self
7979 {
8080 $ new = clone $ this ;
81- $ new ->jobOptions [' retry_limit ' ] = $ maxRetries ;
81+ $ new ->jobOptions [JobOptions:: RETRY_LIMIT ] = $ maxRetries ;
8282
8383 return $ new ;
8484 }
8585
8686 public function withDisabledRetries () : self
8787 {
8888 $ new = clone $ this ;
89- $ new ->jobOptions ['retry_limit ' ] = 0 ;
89+ $ new ->jobOptions [JobOptions::RETRY_LIMIT ] = 0 ;
90+
91+ return $ new ;
92+ }
93+
94+ public function withRecurrenceInterval (int $ interval ) : self
95+ {
96+ $ new = clone $ this ;
97+ $ new ->jobOptions [JobOptions::RECURRENCE ] = $ interval ;
98+
99+ return $ new ;
100+ }
101+
102+ public function withDisabledRecurrence () : self
103+ {
104+ $ new = clone $ this ;
105+ unset($ new ->jobOptions [JobOptions::RECURRENCE ]);
90106
91107 return $ new ;
92108 }
@@ -134,7 +150,7 @@ public function withTube(string $tube) : self
134150 public function build () : array
135151 {
136152 return [
137- \array_merge ([' payload ' => $ this ->payload ], $ this ->jobOptions ),
153+ \array_merge ([JobOptions:: PAYLOAD => $ this ->payload ], $ this ->jobOptions ),
138154 $ this ->taskOptions ,
139155 ];
140156 }
0 commit comments