Lund, Sweden • clojure user since the early days, ~2010 • working with clojure professionally the last 4 years • Interested in functional programming languages, distributed systems, like short project names and copper pans
be buffered in different ways • take! or <! gets first element from it, put! or >! appends new one (kinda) • go blocks • all the rest, alts! and friends • transducers and the list goes on...
& Server • SPDY, HTTP2 • Async HTTP Client • not awfull async support (if you messed with jetty6- continuations & other apis, you know what I mean) • Already super stable (looking at you http-kit)
exposed via core.async, should be simple and reuse the same patterns all over the library • Don't trade performance, be a minimalistic layer over Jetty9
such as: - [::error e] - [::close reason] • :in will receive content sent by this connected client • :out will allow you to push content to this connected client and close the socket
for the client, the only differences are: • partial request map, obviously • the root function name is different Underlying type and implementation are shared
with "control" channels is something fairly common. No need to learn new abstractions, it's all the same type of values and they can be dealt with the same way.
central configuration point for network parameters (such as idle timeouts) and HTTP parameters (such as whether to follow redirects). HttpClient transparently pools connections to servers, but allows direct control of connections for cases where this is needed. HttpClient also acts as a central configuration point for cookies, via getCookieStore().
from users;") (fn [rows-or-exception] (do-something rows))) ;; the eating your tail, useless way, blocking on single async task... (def rows-or-exception (<!! (execute-chan session "select * from users;")))
(<! (execute-chan session "select * from foo;")) bar (<! (execute-chan session "select * from bar;")) baz (<! (execute-chan session "select * from baz;"))] (concat foo bar baz))) This works, but we could do better... In this case Alia does the queries asynchronously but in the order they are in the code, parking treads until query A is realized before moving on to B etc... In that example there's no dependency between a result-set and another, we can improve this.
queries remaining queries [(alia/execute-chan session (select :foo)) (alia/execute-chan session (select :bar)) (alia/execute-chan session (select :baz))] ;; where we'll store our results query-results '()] ;; If we are done with our queries return them, it's the exit clause (if (empty? queries) query-results ;; else wait for one query to complete (first completed first served) (let [[result channel] (alts! queries)] (println "Received result: " result " from channel: " channel) (recur ;; we remove the channel that just completed from our ;; pending queries collection (remove #{channel} queries) ;; and finally we add the result of this query to our ;; bag of results (conj query-results result))))))
couple of helpers such as the previously mentioned + let & <! in go blocks works wonders TLDR Just create fns that returns channels and compose over them
asynchronous under the hood • Queries over large dataset are not memory hogs if handled properly • fetch-size is configurable • fetch-size + c.c.async buffer size combo!
guess from a fetch size at query level or cluster level, or just default to (chan) meaning you will need to have a consumer if you dont' want the channel feeding to halt.
• lazy sequence over queries+predicates • basically supports everything Datastax's java-driver has to offer • hides the ugly from java (type coercion etc...)
object store compatible with the industry-standard S3 API • https://github.com/pyr/cyanite Cassandra backed carbon daemon and metric web service • https://github.com/MastodonC/kixi.hecuba A data platform built with Clojure, ClojureScript, core.async, Om, Cassandra and other technologies
a fixed size thread pool • dont do blocking IO in go blocks! • put! internal queue size • exception handling • difficult to mix blocking and non-blocking, you often lose the advantage of one/both, Alia+Jet are a nice fit in this respect