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
import java.net.InetSocketAddress | |
import java.util.concurrent.Executors | |
import org.jboss.netty.bootstrap.ClientBootstrap | |
import org.jboss.netty.buffer.ChannelBuffers | |
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory | |
import org.jboss.netty.channel._ | |
import org.jboss.netty.util.CharsetUtil | |
import org.jboss.netty.handler.codec.http.HttpClientCodec | |
object Client { |
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
project.clj | |
(defproject tcp-test "0.1.0-SNAPSHOT" | |
:dependencies [[org.clojure/clojure "1.4.0"] | |
[aleph "0.3.0-SNAPSHOT"] | |
[org.clojure/tools.cli "0.2.1"]] | |
:main tcp-test.core) | |
core.clj |
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
(defroutes routes | |
(GET "/" [] (index)) | |
(GET "/events" [] (wrap-aleph-handler events-handler))) | |
(def app | |
(-> handler | |
wrap-error-handling)) | |
(defn start | |
[port] |
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
(defmacro defupdate | |
[multi-fn dispatch-value & body-fn] | |
`(. ~(with-meta multi-fn {:tag 'clojure.lang.MultiFn}) | |
addMethod | |
~dispatch-value | |
(fn [{:keys [action# verb# body#]}] | |
(fn [channel# state#] | |
(let [result# (apply ~@body-fn (state# body#))] | |
(enqueue-and-close channel# (:response result#)) | |
(log/info "update" result#) |
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
(def a (agent 1)) | |
(set-error-mode! a :fail) | |
(set-error-handler! a (fn [failed-agent exception] | |
(println "error-handler" failed-agent exception) | |
(restart-agent failed-agent @failed-agent) | |
(println "restart done"))) | |
(send a / 0) | |
(await a) |
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
(defproject chunked-transfer "0.1.0-SNAPSHOT" | |
:dependencies [[org.clojure/clojure "1.4.0"] | |
[aleph "0.3.0-SNAPSHOT"] | |
[ring "1.1.1"] | |
[compojure "1.1.1"] | |
[cheshire "4.0.1"]] | |
:jvm-opts ["-Djava.awt.headless=true"] | |
:main chunked-transfer.core) | |
(ns chunked-transfer.core |
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 example.registry | |
(:require [zookeeper :as zk])) | |
(def ^:dynamic *registry* nil) | |
(defprotocol Registry | |
(register [this id]) | |
(deregister [this id]) | |
(defrecord InMemoryRegistry [store] |
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 a) | |
(def ^:dynamic *p* nil) | |
(defprotocol P | |
(f [this])) | |
(deftype Foo [] | |
P | |
(f [this] |
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
// Copyright (c) 2016 Juan Delgado (JuDelCo) | |
// License: MIT License | |
// MIT License web page: https://opensource.org/licenses/MIT | |
#include "EntitasPP/SystemContainer.hpp" | |
#include "EntitasPP/Matcher.hpp" | |
#include "EntitasPP/Pool.hpp" | |
#include <iostream> | |
#include <string> |