Created
January 31, 2020 12:48
-
-
Save kovacshuni/a577cfdc9c008d8ff954eae63aca7d66 to your computer and use it in GitHub Desktop.
pureconfig-configreader-example
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
implicit val awsConfigReader: ConfigReader[AWSConfig] = ConfigReader.fromCursor[AWSConfig] { cur => | |
for { | |
objCur <- cur.asObjectCursor | |
maxConnections <- objCur.atKey("max-connections") | |
maxConnectionsInt <- maxConnections.asInt | |
maxErrorRetry <- objCur.atKey("max-error-retry") | |
maxErrorRetryInt <- maxErrorRetry.asInt | |
endpoint <- objCur.atKey("endpoint") | |
endpointStr <- endpoint.asString | |
region <- objCur.atKey("region") | |
regionStr <- region.asString | |
} yield BaseAWSConfig( | |
maxConnections = Option(maxConnectionsInt), | |
maxErrorRetry = Option(maxErrorRetryInt), | |
endpoint = Option(endpointStr), | |
region = Option(regionStr).map(Regions.fromName) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment