Skip to content

Instantly share code, notes, and snippets.

@kovacshuni
Created January 31, 2020 12:48
Show Gist options
  • Save kovacshuni/a577cfdc9c008d8ff954eae63aca7d66 to your computer and use it in GitHub Desktop.
Save kovacshuni/a577cfdc9c008d8ff954eae63aca7d66 to your computer and use it in GitHub Desktop.
pureconfig-configreader-example
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