Created
February 21, 2018 18:45
-
-
Save leikahing/a1847186e5090fef482b505a173d3ca4 to your computer and use it in GitHub Desktop.
A really quick Clojure program that validates the existence of files in S3
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
(ns migratool.core | |
(:gen-class) | |
(:require [clojure.string :as string] | |
[amazonica.core :refer :all] | |
[amazonica.aws.s3 :as s3] | |
[com.climate.claypoole :as cp])) | |
(def access-key "") | |
(def secret-key "") | |
(def bucket "") | |
(def creds {:access-key access-key :secret-key secret-key :endpoint ""}) | |
(defn verify-object [object-name] | |
(let [exists (s3/does-object-exist creds bucket object-name)] | |
(cond (false? exists) (do (println object-name) "") | |
:else ""))) | |
(defn check-files [files region] | |
(cp/with-shutdown! [net-pool (cp/threadpool 40)] | |
(def rsps (cp/upmap net-pool verify-object files)) | |
(doall rsps))) | |
(defn -main | |
"I don't do a whole lot ... yet." | |
[& args] | |
(let [contents (string/split-lines (slurp ""))] | |
(do | |
(check-files contents "ap-northeast-1")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment