Created
December 30, 2011 08:55
-
-
Save codification/1538837 to your computer and use it in GitHub Desktop.
Graphite client in clojure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns clj-client.core | |
(import [java.net Socket] | |
[java.io PrintWriter])) | |
(defn now [] | |
(int (/ (System/currentTimeMillis) 1000))) | |
(defn write-metric [name value timestamp] | |
(with-open [socket (Socket. "localhost" 2003) | |
os (.getOutputStream socket)] | |
(binding [*out* (PrintWriter. os)] | |
(println name value timestamp)))) | |
(defn write-metric2 [name value timestamp] | |
(-> (Socket. "localhost" 2003) | |
(.getOutputStream) | |
(PrintWriter.) | |
(.println (str name value timestamp)))) | |
(defn write-metric3 [name value timestamp] | |
(binding [*out* (-> (Socket. "localhost" 2003) | |
(.getOutputStream) | |
(PrintWriter.))] | |
(println name value timestamp))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment