Skip to content

Commit

Permalink
Add support legacy wave retry [ci fast]
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Jun 22, 2023
1 parent aa4ac11 commit 73a1e7d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class WaveConfig {
this.strategy = parseStrategy(opts.strategy)
this.bundleProjectResources = opts.bundleProjectResources
this.reportOpts = new ReportOpts(opts.report as Map ?: Map.of())
this.retryOpts = new RetryOpts(opts.retryPolicy as Map ?: Map.of())
this.retryOpts = retryOpts0(opts)
this.httpClientOpts = new HttpOpts(opts.httpClient as Map ?: Map.of())
if( !endpoint.startsWith('http://') && !endpoint.startsWith('https://') )
throw new IllegalArgumentException("Endpoint URL should start with 'http:' or 'https:' protocol prefix - offending value: $endpoint")
Expand All @@ -86,6 +86,15 @@ class WaveConfig {

String cacheRepository() { cacheRepository }

private RetryOpts retryOpts0(Map opts) {
if( opts.retryPolicy )
return new RetryOpts(opts.retryPolicy as Map)
if( opts.retry ) {
log.warn "Configuration options 'wave.retry' has been deprecated - replace it with 'wave.retryPolicy'"
return new RetryOpts(opts.retry as Map)
}
return new RetryOpts(Map.of())
}
protected List<String> parseStrategy(value) {
if( !value ) {
log.debug "Wave strategy not specified - using default: $DEF_STRATEGIES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ class WaveConfigTest extends Specification {
opts.retryOpts().jitter == 1.0d
opts.retryOpts().delay == Duration.of('1s')
opts.retryOpts().maxDelay == Duration.of('10s')

// legacy
when:
opts = new WaveConfig([retry:[ maxAttempts: 10, jitter: 2.0, delay: '3s', maxDelay: '40s' ]])
then:
opts.retryOpts().maxAttempts == 10
opts.retryOpts().jitter == 2.0d
opts.retryOpts().delay == Duration.of('3s')
opts.retryOpts().maxDelay == Duration.of('40s')
}

def 'should get http config options' () {
Expand Down

0 comments on commit 73a1e7d

Please sign in to comment.