Skip to content

Instantly share code, notes, and snippets.

@dbousamra
Created June 29, 2015 02:14
Show Gist options
  • Select an option

  • Save dbousamra/46bdd00666da83b465b1 to your computer and use it in GitHub Desktop.

Select an option

Save dbousamra/46bdd00666da83b465b1 to your computer and use it in GitHub Desktop.
def getSnapshotForTable(key: SnapshotKey, tableName: TableName): Either[AmazonClientException, Option[Snapshot]] = ???
def getSnapshot(key: SnapshotKey): Either[AmazonClientException, Option[Snapshot]] = {
val fallbackTableName = tableNameFactory.tableConfig.fallbackTableName.map(PrefixOnlyTableName(_, ""))
val tableNames: List[TableName] = (List(Some(tableNameFactory.fromSnapshotKey(key))) :+ fallbackTableName).flatten
val futures = Future.sequence(tableNames.map(tableName => {
Future { getSnapshotForTable(key, tableName) }
}))
val results: List[Either[AmazonClientException, Option[Snapshot]]] = Await.result(futures, Duration.Inf)
?????????????
How to take the first one that has a Some(snapshot), else the first Error?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment