forked from raystack/firehose
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makes error type for retryable error configurable through env
- Loading branch information
1 parent
312cc13
commit 6a706cb
Showing
6 changed files
with
63 additions
and
9 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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/gotocompany/firehose/config/converter/GrpcSinkRetryErrorTypeConverter.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,14 @@ | ||
package com.gotocompany.firehose.config.converter; | ||
|
||
import com.gotocompany.depot.error.ErrorType; | ||
import org.aeonbits.owner.Converter; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Locale; | ||
|
||
public class GrpcSinkRetryErrorTypeConverter implements Converter<ErrorType> { | ||
@Override | ||
public ErrorType convert(Method method, String s) { | ||
return ErrorType.valueOf(s.trim().toUpperCase(Locale.ROOT)); | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
src/test/java/com/gotocompany/firehose/converter/GrpcSinkRetryErrorTypeConverterTest.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,28 @@ | ||
package com.gotocompany.firehose.converter; | ||
|
||
import com.gotocompany.depot.error.ErrorType; | ||
import com.gotocompany.firehose.config.converter.GrpcSinkRetryErrorTypeConverter; | ||
import org.junit.Test; | ||
import org.junit.jupiter.api.Assertions; | ||
|
||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
|
||
public class GrpcSinkRetryErrorTypeConverterTest { | ||
@Test | ||
public void shouldConvertToAppropriateEnumType() { | ||
Map<String, ErrorType> stringToExpectedValue = Arrays.stream(ErrorType.values()) | ||
.collect(Collectors.toMap(ErrorType::toString, Function.identity())); | ||
GrpcSinkRetryErrorTypeConverter grpcSinkRetryErrorTypeConverter = new GrpcSinkRetryErrorTypeConverter(); | ||
|
||
stringToExpectedValue.keySet().stream() | ||
.forEach(key -> { | ||
ErrorType expectedValue = stringToExpectedValue.get(key); | ||
ErrorType actualValue = grpcSinkRetryErrorTypeConverter.convert(null, key); | ||
Assertions.assertEquals(expectedValue, actualValue); | ||
}); | ||
} | ||
} |
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