Skip to content

Commit

Permalink
v0.1.6: Upgrade to Sente 1.3.0 and Reagent 0.5.0-alpha
Browse files Browse the repository at this point in the history
Changes in handling UID from client. Also: React removed from bower dependencies,
comes from Reagent now.
  • Loading branch information
matthiasn committed Feb 15, 2015
1 parent fcfe5be commit 03aa0bd
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 21 deletions.
1 change: 0 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"tests"
],
"dependencies": {
"react": "~0.11.2",
"pure": "~0.5.0"
}
}
6 changes: 3 additions & 3 deletions example/project.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(defproject example "0.1.5"
(defproject example "0.1.6"
:description "Example Application for Inspect Library"
:url "https://github.com/matthiasn/inspectE"
:url "https://github.com/matthiasn/inspect"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[com.matthiasnehlsen/inspect "0.1.5"]
[com.matthiasnehlsen/inspect "0.1.6"]
[clj-pid "0.1.1"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]]

Expand Down
7 changes: 4 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject com.matthiasnehlsen/inspect "0.1.6-SNAPSHOT"
(defproject com.matthiasnehlsen/inspect "0.1.6"
:description "Log to a web application to inspect what's going on in your application"
:url "https://github.com/matthiasn/inspect"
:license {:name "Eclipse Public License"
Expand All @@ -8,15 +8,15 @@
[org.clojure/tools.logging "0.3.0"]
[org.clojure/tools.namespace "0.2.7"]
[ch.qos.logback/logback-classic "1.1.1"]
[com.taoensso/sente "1.2.0"]
[com.taoensso/sente "1.3.0"]
[org.clojure/core.match "0.2.1"]
[http-kit "2.1.19"]
[compojure "1.2.1"]
[ring "1.3.1"]
[ring/ring-defaults "0.1.1"]
[clj-time "0.8.0"]
[org.clojure/clojurescript "0.0-2760"]
[reagent "0.4.3"]
[reagent "0.5.0-alpha"]
[com.stuartsierra/component "0.2.2"]]

:source-paths ["src/clj/"]
Expand All @@ -27,4 +27,5 @@
:source-paths ["src/cljs"]
:compiler {:output-to "resources/public/inspect/js/build/inspect-opt.js"
:optimizations :advanced
:preamble ["reagent/react.min.js"]
:externs ["externs/misc.js"]}}]})
1 change: 0 additions & 1 deletion resources/public/inspect/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ <h1 class="splash-head">inspect</h1>
</div>

<!-- Scripts placed at the end of the document so the pages load faster -->
<script src="/inspect/bower_components/react/react.min.js"></script>
<script src="/inspect/js/build/inspect-opt.js"></script>

</body>
Expand Down
16 changes: 5 additions & 11 deletions src/clj/com/matthiasnehlsen/inspect/matcher.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[com.stuartsierra.component :as component]
[clojure.core.async :as async :refer [chan <! >! put! tap untap-all timeout go-loop]]))

(defn- user-id-fn
(defn user-id-fn
"generates unique ID for request"
[req]
(let [uid (str (java.util.UUID/randomUUID))]
Expand All @@ -18,21 +18,15 @@
(def client-maps (atom {}))
(def stats (atom {}))

(defn strip-uid
"for some reason, the :client-uuid is longer than expected. This strips the
uuid string to the expected length as used elsewhere"
[client-uuid]
(subs client-uuid 0 36))

(defn get-next-items
"start listener for all event types, limited to the next n for each"
[inspect-chan client-map full-event]
(put! inspect-chan [:next (strip-uid (:client-uuid full-event)) client-map]))
(put! inspect-chan [:next (:client-uuid full-event) client-map]))

(defn initialize-inspector
"start listener for all event types, limited to the next n for each"
[params full-event chsk-send!]
(let [uid (strip-uid (:client-uuid full-event))
(let [uid (:uid params)
n (:n params)
client-map (into {} (map (fn [[t _]] [t n]) (seq @stats)))]
(swap! client-maps assoc-in [uid] client-map)
Expand Down Expand Up @@ -60,10 +54,10 @@
(match event
[:cmd/get-next-items params] (get-next-items inspect-chan params full-event)
[:cmd/initialize params] (initialize-inspector params full-event chsk-send!)
[:cmd/get-stats] (chsk-send! (strip-uid (:client-uuid full-event)) [:info/stats @stats])
[:cmd/get-stats params] (chsk-send! (:uid params) [:info/stats @stats])
[:chsk/ws-ping] () ; currently just do nothing with ping (no logging either)
[:chsk/uidport-open] () ; user-id-fn already logs established connection
[:chsk/uidport-close] (close-connection inspect-chan (strip-uid (:client-uuid full-event)))
[:chsk/uidport-close] (close-connection inspect-chan (:client-uuid full-event))
:else (log/debug "Unmatched event:" event)))))

(defn handle-event
Expand Down
4 changes: 2 additions & 2 deletions src/cljs/inspect/communicator.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
[:info/client-map client-map] (reset! appstate/client-map client-map)
:else (print "Unkown msg-type " payload))
[:chsk/state state] (when (:open? state)
(chsk-send! [:cmd/get-stats])
(chsk-send! [:cmd/initialize {:n 10}]))
(chsk-send! [:cmd/get-stats {:uid (:uid @chsk-state)}])
(chsk-send! [:cmd/initialize {:n 10 :uid (:uid @chsk-state)}]))
:else (print "Unmatched event: %s" event)))

(defonce chsk-router (sente/start-chsk-router! ch-chsk event-handler))

0 comments on commit 03aa0bd

Please sign in to comment.