Fork me on GitHub

I note that doall is just a pun for dorun. Should one of them be preferred?


Wow I can't read the docs. dorun always returns nil, where doall always returns the forced coll. My bad.


arrdem: there is a good site called grimoire where you can look docs up


Hello simple_smile I'm wondering why a particular automat build in Travis CI passed despite ClassNotFoundExceptions ... the related snippet is in #C0AB48493


what mustache library do you recommend?


(= "you" everyone)


I don't use mustache personally, but I've heard stencil is pretty nice.


Leiningen uses Stencil for templates.


Anybody have a clever way to turn a vector of maps with the same structure into a single map keyed by one of the keys in the map. For example, {{:a 1, :b 2}, {:a 3 :b 4}] => {1 {:a 1 :b 2}, 3 {:a 3 : b 4}}


Best I can come up with is (zipmap (map :a v) v)


But it's not as efficient as a reduce


(group-by :a) ?


Close, but I don't want it to give me a vector of results for each key


Good idea about group-by, though. I looked at the source and it uses a reduce with transients. I might get some extra points for using transients simple_smile


@jean @seancorfield @delaguardo Thanks! I'll go with stencil for now.


I've defined a macro that generates a function


(defmacro def-errors [k v]
  `(defn ~(-> k name symbol) []
     (error-page ~v)))


macroexpand tells me it works


(macroexpand (def-errors :404 "404"))
=> #'edubot.pages.errors/404


my intention is to loop over a map and generate functions based on that


(def error-map {:error-403 "Error 403. Permission Denied."
                :error-404 "Error 404. Page Not Found."})

(for [[k v] error-map]
  (def-errors k v))


but the output of the last expression is just multiple definitions of function k:

=> (#'edubot.pages.errors/k #'edubot.pages.errors/k)


I've already confirmed that k and v in the for loop are mapped correctly to the keywords and strings separately


what is causing this behaviour?


the macro receives k as the argument


not the value of k


to do stuff like that dynamically you'll need eval or intern the vars directly


hmm let me retry


I was trying to #_-comment a thing with metadata and found out that it's enough to comment out the meta data like this: #_^{:key :a} [:a]. However, before that I tried to comment out both the meta data and the value itself, and got a result I don't understand: [#_^{:key :a} #_[:a] ^{:key :b} [:b]] is not [:b] but []. Why?


Well, exact answer would require someone who knows the Clojure reader Java code, but it looks as if Clojure reader pushes the reader macros on a stack and then applies it to forms by pushing from that stack. So this reader macro will then apply to the next form that's read, and since #_ comments out both metadata and the form it will be ^{:key :b} [:b].


I guess this would also explain this code - - people were wondering about here not long ago.


@danielwoelfel: (into {} (map (juxt :a identity)) [{:a 1 😛 2} {:a 2 😛 3}])


not sure how fast it is though


oops without the smileys simple_smile


i am using core.async. my question is if i thread(while true ( go some function))). would it end up running out of server resource?


i am new to core.async. and there is API usage, but not much info about design patterns


i am working on a web service, about 1 million msg per day


it's like get a request, use some other web service to enrich it, and save it to db


so i am designing it like 3 channels, and thread read from channel, and go call a web service, after get response, save to the next channel.


the point is , the second service is slow, so some times the first channel exceed its limit.


i am not sure i am using it right


@seancorfield: lein now supports using a custom renderer too, you can pass it in to renderer when you initialize it


hey @jarodzz, those are common issues- multiple collaborating services in a pipeline taking differing amounts of time. in those cases it's up to you to decide, based on the requirements of the overall problem you're solving, what policies, or business rules, you want to have to handle the different circumstances. once you have clarity on your rules, then you can settle on an architecture/implementation, which maybe uses core.async or maybe does not. for example, if the goal of the web service is just to save/ack this incoming data, and the response doesn't depend on the enrichment step, then you might just want to write the incoming requests directly to the db, and set up a background task to ensure that each of them is appropriately enriched. in contrast, if the web service responses depend on the enrichment step, then you basically have a synchronous problem and you need to provision for 1M calls/day to the enrichment service- or find a faster enrichment service (or maybe employ a cache, etc) lots of variations in between those, but try to define the policies you want to have first, and then see if core.async is an appropriate mechanism


@jonahbenton: thanks for the details. in this case, i do need a realtime response.


the prototype works with a queue, as a temp buffer. but my problem is, if i read 1k from queue, go call step1, async put results to channel 1. then read from channel1 to go call step2. but if step2 is slow, i need to wait for it is empty to get new requests. i have no way to tell whether a channel is empty


gotcha. so it sounds like the use of core.async has introduced a dependency between the slowness of the enrichment and your ability to service new requests? because you are waiting to deliver a response to request 1 before serving request 2?


y. something like that. more like if i have 3 channel, moving requests 1->2->3, each step will enrich something. but i can't get new requests before channel1 is empty. otherwise, it's gonna fail at >!! ch


but i can't tell when channel1 is empty.


maybe i am using it wrong. simple_smile. i'm reading some core.async articles from reddit.


An #onyx / #datomic experience report written by @robert-stuttaford, that some of you may be interested in "just a small experience report which i hope will help some other Onyx users out:"


oh, heh, yeah simple_smile any questions most welcome!


@jarodzz yeah, it's a neat pattern, but it sounds like it doesn't capture the semantics you need. what you need is a synchronous pipeline that takes a ticker, downloads the ticker data, transforms, and then inserts, e.g. (-> ticker download transform insert). your web service handler could spin up a go block for each incoming ticker, and wait on a channel for the insert to complete to return a result to the user.


got it. i'll give it a try. thanks,


Good to know! I’ll have to take a closer look as I’m building a template system for Boot right now, based on Leiningen.


@jarodzz: there was an interesting post in the google group about a similar problem recently:


@mpenet: you’re welcome 😛


has anyone tried interacting with a C# service through REST?


It shouldn’t matter if the service is sending back JSON.


Look into Cheshire for JSON processing (


hi - I’m working with multimethods and am trying to write a dispatch method based on class for Byte-Arrays. I’m not having much luck. Anyone have a tip for what I might use to dispatch on this?


I think I’ve found it (defmethod encrypt (Class/forName "[B") [key message]. simple_smile