       (scheduler-put! job)))
   )
 
-(defn run-index-all [db]
+(defn schedule-jobs-all [db]
   (do
     ;; add jobs to scheduler in sequence
 

    ))


(defn run [& {:keys [db index-revision-number index-id skip-create-snapshot]
              :or {db (d/db datomic-conn)
                   index-revision-number 0
                   index-id (format "%s_v%s" release-id index-revision-number)}}]
  (let []
    (do
      (create-index index-id
                    :default-index (= index-revision-number 0)
                    :delete-existing true)
      (let [n-threads 4
            logger (chan n-threads)]


                    (recur)))
                (close! logger)))))

        )

      )))


(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (let [index-revision-number (or (first args) 0)
        index-id (format "%s_v%s" release-id index-revision-number)
        repository-name "s3_repository"]
    (do
      (println "Indexer starting!")
      (mount/start)
      (es-connect)
      (create-index index-id
                    :default-index (= index-revision-number 0)
                    :delete-existing true)
      (let [db (d/db datomic-conn)]
        (do
          (run db)
          (schedule-jobs-all db)))
      (connect-snapshot-repository repository-name)
      (let [snapshot-id (get-next-snapshot-id repository-name release-id)]
        (save-snapshot index-id repository-name snapshot-id))
      (mount/stop)))
  )
