Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this is really stupid but I just need a test harness for now
- Loading branch information
0 parents
commit eb33283
Showing
7 changed files
with
558 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/target | ||
/lib | ||
/classes | ||
/checkouts | ||
pom.xml | ||
pom.xml.asc | ||
*.jar | ||
*.class | ||
.lein-deps-sum | ||
.lein-failures | ||
.lein-plugins | ||
.lein-repl-history |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# revise | ||
|
||
A Clojure library designed to ... well, that part is up to you. | ||
|
||
## Usage | ||
|
||
FIXME | ||
|
||
## License | ||
|
||
Copyright © 2013 FIXME | ||
|
||
Distributed under the Eclipse Public License, the same as Clojure. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Introduction to revise | ||
|
||
TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(defproject revise "0.0.1-SNAPSHOT" | ||
:description "RethinkDB client for Clojure" | ||
:url "github.com/bitemyapp/revise/" | ||
:license {:name "Eclipse Public License" | ||
:url "http://www.eclipse.org/legal/epl-v10.html"} | ||
:main revise.core | ||
:dependencies [[org.clojure/clojure "1.5.1"] | ||
[gloss "0.2.2-beta4"] | ||
[org.flatland/protobuf "0.7.1"]]) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
(ns revise.core | ||
(:use [clojure.java.io] | ||
[flatland.protobuf.core] | ||
[gloss.core] | ||
[gloss.io]) | ||
(:import [java.net Socket] | ||
[java.io PrintWriter InputStreamReader BufferedReader OutputStream]) | ||
(:gen-class :main true)) | ||
|
||
(import Rethinkdb$VersionDummy) | ||
|
||
(def version-frame (compile-frame {:a :int32-le})) | ||
(defn gen-ver [val] | ||
(contiguous (encode version-frame {:a val}))) | ||
|
||
(def VersionDummy (protodef Rethinkdb$VersionDummy)) | ||
|
||
(def host {:name "localhost" :port 28015}) | ||
|
||
(def magic-number 1063369270) | ||
(def version (protobuf-dump (protobuf VersionDummy :Version magic-number))) | ||
(def ver-frame (gen-ver magic-number)) | ||
;; (println (str "ver-frame: " (.get ver-frame))) | ||
;; 0x3f61ba36 | ||
|
||
(declare conn-handler) | ||
|
||
(defn connect [server] | ||
(let [socket (Socket. (:name server) (:port server)) | ||
in (BufferedReader. (InputStreamReader. (.getInputStream socket))) | ||
out (PrintWriter. (.getOutputStream socket)) | ||
conn (ref {:in in :out out})] | ||
(doto (Thread. #(conn-handler conn)) (.start)) | ||
conn)) | ||
|
||
(defn write [conn msg] | ||
; (println (str "being sent: " msg)) | ||
(doto (:out @conn) | ||
(.write msg) | ||
(.flush))) | ||
|
||
(defn conn-handler [conn] | ||
(while (nil? (:exit @conn)) | ||
(let [msg (.readLine (:in @conn))] | ||
(when msg | ||
(println msg))))) | ||
|
||
;; (def rdb (connect host)) | ||
|
||
(def sock (java.net.Socket. "localhost" 28015)) | ||
|
||
(def write-stream (writer sock)) | ||
(def read-stream (reader sock)) | ||
|
||
(defn read-loop [] | ||
(loop [buffer ""] | ||
;;(println (str "Looping.. -> " buffer)) | ||
(let [nbuf (parseMessage buffer) | ||
nchr (.read read-stream) ] | ||
(if-not (= nchr -1) | ||
(recur (str nbuf (char nchr))))))) | ||
|
||
(defn write-s [message] | ||
(.write write-stream message) | ||
(println (str "-> " message)) | ||
(.flush write-stream)) | ||
|
||
(defn -main [& args] | ||
;; (write rdb magic-number) | ||
(write-s magic-number) | ||
(read-loop)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns revise.core-test | ||
(:use clojure.test | ||
revise.core)) | ||
|
||
(deftest a-test | ||
(testing "FIXME, I fail." | ||
(is (= 0 1)))) |