in src/main/scala/com/gu/dynamodbswitches/Switches.scala [18:34]
def update(): Unit = {
try {
val scanRequest: ScanRequest = ScanRequest.builder().tableName(dynamoDbTableName).build()
val results = dynamoDbClient.scan(scanRequest).items().asScala.toList.map(_.asScala.toMap)
val ProcessingResults(updates, missing) = processor.process(results)
if (missing.nonEmpty) {
warn(s"DynamoDB did not return some switches: ${missing.toList.map(_.name).sorted.mkString(", ")}")
}
for ((switch, newState) <- updates) {
info(s"Setting switch ${switch.name} to ${newState.toString}")
switch.enabled = newState
}
} catch {
case exception: SdkServiceException =>
error(s"Encountered Amazon service error when trying to update switches from DynamoDB: ${exception.getMessage}")
}
}