                         (s1st/ring collect-audit-logs audit-logs audit-logs-bucket)
                         (s1st/executor :resolver resolver-fn))]
 
+        (merge component {:audit-logs-bucket audit-logs-bucket
+                          :audit-logs        audit-logs})
+
         (if (:no-listen? configuration)
-          (merge component {:httpd         nil
-                            :hystrix-httpd nil
-                            :handler       handler})
-          (merge component {:httpd         (jetty/run-jetty handler (merge configuration
-                                                                           {:join? false}))
-                            :hystrix-httpd (run-hystrix-jetty (merge configuration {:join? false
-                                                                                    :port  7979}))
-                            :handler       handler}))))))
+          (merge component {:httpd                nil
+                            :hystrix-httpd        nil
+                            :handler              handler
+                            :audit-log-flush-pool nil})
+          (merge component {:httpd                (jetty/run-jetty handler (merge configuration
+                                                                                  {:join? false}))
+                            :hystrix-httpd        (run-hystrix-jetty (merge configuration {:join? false
+                                                                                           :port  7979}))
+                            :handler              handler
+                            :audit-log-flush-pool (schedule-audit-log-flusher audit-logs-bucket audit-logs configuration)}))))))
 
 (defn stop-component
   "Stops the http component."

      (log/info "Stopping HTTP daemon.")
      (when-not (:no-listen? (:configuration component))
        (.stop (:httpd component))
        (.stop (:hystrix-httpd component)))
      (merge component {:httpd         nil
                        :hystrix-httpd nil
                        :handler       nil}))))

(defmacro def-http-component
  "Creates an http component with your name and all your given dependencies. Those dependencies will also be available

  "Adds a list of log entries to the audit logs container."
  [audit-logs logs]
  (dosync
    (alter audit-logs concat logs)))

(defn empty-logs
  "Returns all current audit logs and resets the container to empty."
  [audit-logs]
  (dosync
    (let [previous-logs @audit-logs]
      (ref-set audit-logs [])
      previous-logs)))

(defn is-modifying? [{:keys [request-method]}]
  (some #(= % request-method) [:post :put :patch :delete]))

(defn collect-audit-logs
  "Adds request map to audit-logs container."
