 
   [:require [clojure.string :as string]]
   [:use [korma.db]]
+  [:use [clojure.core.async :only [go <! >!]]]
   [:require [korma.core]]
   [:use [webapp-config.settings]]
   [:use [webapp.framework.server.encrypt]]

(defn next-realtime-id [] (swap! realtime-counter inc))

(def my-pool (mk-pool))
(every 10000 (fn []
              (let [sql (str "update coils_realtime_log"
                            "      set record_status = 'PROCESSING',"
                            "          realtime_jvm_id = ? "
                            "where "

                            "                    coils_realtime_log"
                            "              WHERE "
                            "                   record_status='WAITING' LIMIT 1 ) "
                    )

                    get-realtime-log-entry (str "select * from coils_realtime_log "
                                                "WHERE "
                                                "realtime_jvm_id = ?")
                    ]
                     (do
                        (korma.core/exec-raw [sql [next-id]] [])
                        (let [realtime-log-entry-list
                              (korma.core/exec-raw [get-realtime-log-entry [next-id]] :results)
                              realtime-log-entry (first realtime-log-entry-list)
                              ]
                          (if realtime-log-entry
                            (>! server-side-record-changes  realtime-log-entry))
                          )
                 ))) my-pool )





( go
  (loop []
        (let [realtime-log-entry   (<! server-side-record-changes)]
                             (println realtime-log-entry  )
(recur))))
