 
 (defn generate-event [root-url url body]
   {:timestamp (System/currentTimeMillis)
-   :sourceId root-url
+   :sourceId url
    :rootUrl root-url
    :eventName "web-crawl"
    :url url

    (locking this
      (when-not @running
        (reset! running true)
        (reset! crawler (create-crawler root-url url-limit))
        (log/info "Started WebCrawlerSource"))))

  (stop [this]
    (locking this
      (when @running
        (spider/stop-workers @crawler) ;;blocking call
        (reset! running false)
        (log/info "Stopped WebCrawlerSource")))))


(defn web-source
  [{:keys [ root-url page-crawl-limit]}]
  (let [source (WebSource. root-url page-crawl-limit (atom nil) (atom nil))]
    (add-data-source :web-source source)))

(comment

(ns hydrant.sources.web
  (:require [itsy.core :as spider]
            [itsy.extract :refer [html->str]]
            [hydrant.service :refer [Service]]
            [hydrant.core :refer [add-data-source events-to-flows]]
            [taoensso.timbre :as log]))
