-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
163 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.scalecube</groupId> | ||
<artifactId>scalecube-services-parent</artifactId> | ||
<version>2.10.13-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>scalecube-services-security-parent</artifactId> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>services-security</module> | ||
<module>services-security-vault</module> | ||
</modules> | ||
|
||
</project> |
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,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.scalecube</groupId> | ||
<artifactId>scalecube-services-security-parent</artifactId> | ||
<version>2.10.13-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>scalecube-services-security-vault</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.scalecube</groupId> | ||
<artifactId>scalecube-services</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<!-- Other --> | ||
<dependency> | ||
<groupId>io.scalecube</groupId> | ||
<artifactId>config-vault</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.yaml</groupId> | ||
<artifactId>snakeyaml</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
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
File renamed without changes.
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
53 changes: 53 additions & 0 deletions
53
...arent/services-security/src/main/java/io/scalecube/services/security/RetryStrategies.java
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,53 @@ | ||
package io.scalecube.services.security; | ||
|
||
import io.scalecube.security.tokens.jwt.KeyNotFoundException; | ||
import java.time.Duration; | ||
import reactor.util.retry.Retry; | ||
import reactor.util.retry.RetryBackoffSpec; | ||
import reactor.util.retry.RetrySpec; | ||
|
||
public class RetryStrategies { | ||
|
||
private static final int MAX_ATTEMPTS = 20; | ||
private static final Duration MIN_BACKOFF = Duration.ofMillis(200); | ||
private static final Duration MAX_BACKOFF = Duration.ofSeconds(3); | ||
|
||
private RetryStrategies() { | ||
// Do not instantiate | ||
} | ||
|
||
/** | ||
* Returns zero-retries strategy. | ||
* | ||
* @return {@link Retry} instance | ||
*/ | ||
public static Retry noRetriesRetryStrategy() { | ||
return Retry.max(0); | ||
} | ||
|
||
/** | ||
* Returns retry-strategy which reacts on {@link KeyNotFoundException}. | ||
* | ||
* @return {@link RetryBackoffSpec} instance | ||
*/ | ||
public static RetryBackoffSpec keyNotFoundRetryStrategy() { | ||
return RetrySpec.backoff(MAX_ATTEMPTS, MIN_BACKOFF) | ||
.maxBackoff(MAX_BACKOFF) | ||
.filter(ex -> ex instanceof KeyNotFoundException); | ||
} | ||
|
||
/** | ||
* Returns retry-strategy which reacts on {@link KeyNotFoundException}. | ||
* | ||
* @param maxAttempts maxAttempts | ||
* @param minBackoff minBackoff | ||
* @param maxBackoff maxBackoff | ||
* @return {@link RetryBackoffSpec} instance | ||
*/ | ||
public static RetryBackoffSpec keyNotFoundRetryStrategy( | ||
int maxAttempts, Duration minBackoff, Duration maxBackoff) { | ||
return RetrySpec.backoff(maxAttempts, minBackoff) | ||
.maxBackoff(maxBackoff) | ||
.filter(ex -> ex instanceof KeyNotFoundException); | ||
} | ||
} |
File renamed without changes.
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
File renamed without changes.