Created
August 14, 2015 22:47
-
-
Save faermanj/256a4d8873c3ab3fd82d to your computer and use it in GitHub Desktop.
Iterating in reverse dependency order, as asked in http://stackoverflow.com/questions/31688017/how-to-observe-on-reverse-dependency-order/32006887#32006887
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
import scala.collection.JavaConverters._ | |
import com.amazonaws.services.s3.AmazonS3Client | |
import rx.lang.scala._ | |
import rx.lang.scala.schedulers._ | |
import com.amazonaws.services.s3.model._ | |
/** | |
* @author jfaerman | |
*/ | |
object RevDepIterator extends App { | |
val S3 = new AmazonS3Client | |
val buckets = Observable.from { | |
S3.listBuckets.asScala | |
} | |
val things = buckets.flatMap { b => Observable.from( | |
S3.listObjects(new ListObjectsRequest().withBucketName(b.getName)) | |
.getObjectSummaries | |
.asScala) :+ b | |
} | |
for (t <- things) t match { | |
case b:Bucket => println(s"delete bucket ${b.getName}") | |
case o:S3ObjectSummary => println(s"delete object ${o.getBucketName}/${o.getKey}") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment