-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add retry policy in Channel.fromSRA factory (#5389)
Signed-off-by: jorgee <[email protected]> Signed-off-by: Paolo Di Tommaso <[email protected]> Co-authored-by: Paolo Di Tommaso <[email protected]> Co-authored-by: Christopher Hakkaart <[email protected]>
- Loading branch information
1 parent
7bbba67
commit fb1c8b2
Showing
6 changed files
with
251 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
modules/nextflow/src/main/groovy/nextflow/datasource/SraRetryConfig.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2013-2024, Seqera Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package nextflow.datasource | ||
|
||
import groovy.transform.CompileStatic | ||
import groovy.transform.EqualsAndHashCode | ||
import groovy.transform.ToString | ||
import nextflow.util.Duration | ||
/** | ||
* Models retry policy configuration for Sra queries | ||
* | ||
* @author Jorge Ejarque <[email protected]> | ||
*/ | ||
@ToString(includePackage = false, includeNames = true) | ||
@EqualsAndHashCode | ||
@CompileStatic | ||
class SraRetryConfig { | ||
Duration delay = Duration.of('500ms') | ||
Duration maxDelay = Duration.of('30s') | ||
int maxAttempts = 3 | ||
double jitter = 0.25 | ||
|
||
SraRetryConfig() { | ||
this(Collections.emptyMap()) | ||
} | ||
|
||
SraRetryConfig(Map config) { | ||
if( config.delay ) | ||
delay = config.delay as Duration | ||
if( config.maxDelay ) | ||
maxDelay = config.maxDelay as Duration | ||
if( config.maxAttempts ) | ||
maxAttempts = config.maxAttempts as int | ||
if( config.jitter ) | ||
jitter = config.jitter as double | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
modules/nextflow/src/test/groovy/nextflow/datasource/SraRetryConfigTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2013-2024, Seqera Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package nextflow.datasource | ||
|
||
import nextflow.util.Duration | ||
import spock.lang.Specification | ||
|
||
/** | ||
* | ||
* @author Jorge Ejarque <[email protected]> | ||
*/ | ||
class SraRetryConfigTest extends Specification { | ||
|
||
def 'should create retry config'() { | ||
|
||
expect: | ||
new SraRetryConfig().delay == Duration.of('500ms') | ||
new SraRetryConfig().maxDelay == Duration.of('30s') | ||
new SraRetryConfig().maxAttempts == 3 | ||
new SraRetryConfig().jitter == 0.25d | ||
|
||
and: | ||
new SraRetryConfig([maxAttempts: 20]).maxAttempts == 20 | ||
new SraRetryConfig([delay: '1s']).delay == Duration.of('1s') | ||
new SraRetryConfig([maxDelay: '1m']).maxDelay == Duration.of('1m') | ||
new SraRetryConfig([jitter: '0.5']).jitter == 0.5d | ||
|
||
} | ||
} |