Re: [ANN] Prone: Exception/debugging middleware

2014-09-02 Thread László Török
Fantastic!


2014-09-02 5:35 GMT+01:00 Kurt Schrader kschra...@gmail.com:

 Outstanding work!

 Just plugged it locally and used it to debug a particularly hairy issue on
 my side. This is super useful.

 -Kurt


 On Mon, Sep 1, 2014 at 10:48 PM, James Reeves ja...@booleanknot.com
 wrote:

 This looks rather nice. I'll certainly be trying it out.

 - James


 On 2 September 2014 01:06, Colin Fleming colin.mailingl...@gmail.com
 wrote:

  I don't do any web dev myself, but Prone looks really nice -
 congratulations! Great work.

 Cheers,
 Colin


 On 2 September 2014 02:05, Christian Johansen christ...@cjohansen.no
 wrote:

 Hi,

 Prone (http://clojars.org/prone - http://github.com/magnars/prone) is
 a new middleware for Ring apps that replaces the default exception page
 with an interactive page that presents the exception, stack trace and
 environment data in a more easily understandable way. It can also debug
 arbitrary data, and has a nice little client-side data browser. It's
 intention is to make it a lot easier to find the cause of errors when
 working on Clojure web applications.

 Here's a short video demoing it's use:
 https://dl.dropboxusercontent.com/u/3378230/prone-demo.mp4

 Hope you find it useful!

 Christian

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
László Török
Checkout Lollyrewards.com http://www.lollyrewards.com - Giving credit,
getting credit.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using an atom for a caching map

2014-09-02 Thread Michał Marczyk
java.util.concurrent.ConcurrentHashMap has a putIfAbsent method that
could be used with delays to support this use case with a no
recomputation guarantee:

(def chm (java.util.concurrent.ConcurrentHashMap.))

;; this will work as expected whether chm has a value for :foo or not
(let [d (delay (+ 1 2))]
  ;; NB. the two @d expressions refer to different ds
  (if-let [d (.putIfAbsent chm :foo d)] @d @d))
;= 3

;; this will remove all entries
(.clear chm)

No point switching away from Atoms if occasional recomputation is ok
and they perform well enough, of course (and whether this would be an
improvement performance-wise in any given scenario would need to be
determined by benchmarking).


On 2 September 2014 00:54, Marcus Magnusson marx...@gmail.com wrote:
 Forget about sleep, there's work to be done! I realized that the drawback I
 mentioned with my solution, where concurrent calls to the memoized function
 with different sets of arguments would be handled one-by-one, could easily
 be resolved by having the cache inside synced-memoize store futures for
 calculating the value, rather than the value itself - some small changes and
 everything should hopefully work well (don't ask me about overhead, though!)


 (defn synced-memoize [f]
   (let [mem (atom {})
 handle-ch (chan)]
 (go-loop []
   (let [[args ret-ch] (! handle-ch)]
 (! ret-ch (if-let [e (find @mem args)]
  (val e)
  (let [ret (future (apply f args))]
(swap! mem assoc args ret)
ret)))
 (recur)))
 (fn [ args]
   (if-let [e (find @mem args)]
 (deref (val e))
 (let [ret (chan)]
   (!! handle-ch [args ret])
   (deref (!! ret)))

 (def lookup
   (let [calc-value* (synced-memoize calc-value)]
 (fn [cache key]
   (if (contains? @cache key)
 (@cache key)
 ((swap! cache assoc key (calc-value* key)) key)


 Den måndagen den 1:e september 2014 kl. 23:55:58 UTC+2 skrev Marcus
 Magnusson:

 Huh, I gave it some more thought - of course, the reason why memoize won't
 help us here is that there is no synchronization between simultaneous
 invocations with the same set of arguments. This is typically not a problem
 if the underlying function is fast, but in our case it would be neat with an
 alternative. I got the idea of writing a channel-based version of memoize,
 which will ensure that invoking the memoized function simultaneously with
 the same arguments will only call the underlying function once. Below is a
 quick implementation with one obvious drawback (and probably tons of bugs
 and points of improvement!), namely that if the underlying function is
 costly, and we invoke the memoized function with a bunch of different
 non-cached set of arguments, then calculating the values will be done
 one-by-one. This could be fixed for example by having handle-ch delegate to
 another channel, where we have one channel per set of arguments - I'll leave
 that for someone else, or for when I've had some sleep and realized what a
 bad idea it was...  :) Note that I haven't worked much with core.async, and
 that there is probably a much more straightforward solution (for example the
 one given by Thomas Heller), so please let me know of any issues with this:


 (defn synced-memoize [f]
   (let [mem (atom {})
 handle-ch (chan)]
 (go-loop []
   (let [[args ret-ch] (! handle-ch)]
 (! ret-ch (if-let [e (find @mem args)]
  (val e)
  (let [ret (apply f args)]
(swap! mem assoc args ret)
ret)))
 (recur)))
 (fn [ args]
   (if-let [e (find @mem args)]
 (val e)
 (let [ret (chan)]
   (!! handle-ch [args ret])
   (!! ret))

 (def lookup
   (let [calc-value* (synced-memoize calc-value)]
 (fn [cache key]
   (if (contains? @cache key)
 (@cache key)
 (swap! cache assoc key (calc-value* key))



 Den måndagen den 1:e september 2014 kl. 22:35:56 UTC+2 skrev Marcus
 Magnusson:

 I reckon if that worked, there would be no need for memoize anyway, but I
 don't think swap! will allow for it. I'm far from an expert on swap! or
 atoms, but several swap!s may be run simultaneously on a single atom (and
 swap! may re-run the swapping function if the atom has been changed since
 the swapping function was invoked). In other words, if two swap!s are
 invoked at about the same time for the same key (which is not currently in
 the cache), both invocations may be given the same value of the cache at
 that moment, which will lead to the value being re-calculated in both
 invocations - and even if calc-value is memoized, the same thing may occur
 in the memoized function.

 As I said, I'm far from an expert, so I wrote a small test that shows
 that calc-value may indeed be called more than once (core.async here is
 simply to ensure 

Re: Using an atom for a caching map

2014-09-02 Thread Marcus Magnusson
Michał, that's quite a bit more straightforward, nice  :)  Also made me 
realize that I should've used delays in synced-memoize.

Den tisdagen den 2:e september 2014 kl. 10:09:47 UTC+2 skrev Michał Marczyk:

 java.util.concurrent.ConcurrentHashMap has a putIfAbsent method that 
 could be used with delays to support this use case with a no 
 recomputation guarantee: 

 (def chm (java.util.concurrent.ConcurrentHashMap.)) 

 ;; this will work as expected whether chm has a value for :foo or not 
 (let [d (delay (+ 1 2))] 
   ;; NB. the two @d expressions refer to different ds 
   (if-let [d (.putIfAbsent chm :foo d)] @d @d)) 
 ;= 3 

 ;; this will remove all entries 
 (.clear chm) 

 No point switching away from Atoms if occasional recomputation is ok 
 and they perform well enough, of course (and whether this would be an 
 improvement performance-wise in any given scenario would need to be 
 determined by benchmarking). 


 On 2 September 2014 00:54, Marcus Magnusson mar...@gmail.com 
 javascript: wrote: 
  Forget about sleep, there's work to be done! I realized that the 
 drawback I 
  mentioned with my solution, where concurrent calls to the memoized 
 function 
  with different sets of arguments would be handled one-by-one, could 
 easily 
  be resolved by having the cache inside synced-memoize store futures for 
  calculating the value, rather than the value itself - some small changes 
 and 
  everything should hopefully work well (don't ask me about overhead, 
 though!) 
  
  
  (defn synced-memoize [f] 
(let [mem (atom {}) 
  handle-ch (chan)] 
  (go-loop [] 
(let [[args ret-ch] (! handle-ch)] 
  (! ret-ch (if-let [e (find @mem args)] 
   (val e) 
   (let [ret (future (apply f args))] 
 (swap! mem assoc args ret) 
 ret))) 
  (recur))) 
  (fn [ args] 
(if-let [e (find @mem args)] 
  (deref (val e)) 
  (let [ret (chan)] 
(!! handle-ch [args ret]) 
(deref (!! ret))) 
  
  (def lookup 
(let [calc-value* (synced-memoize calc-value)] 
  (fn [cache key] 
(if (contains? @cache key) 
  (@cache key) 
  ((swap! cache assoc key (calc-value* key)) key) 
  
  
  Den måndagen den 1:e september 2014 kl. 23:55:58 UTC+2 skrev Marcus 
  Magnusson: 
  
  Huh, I gave it some more thought - of course, the reason why memoize 
 won't 
  help us here is that there is no synchronization between simultaneous 
  invocations with the same set of arguments. This is typically not a 
 problem 
  if the underlying function is fast, but in our case it would be neat 
 with an 
  alternative. I got the idea of writing a channel-based version of 
 memoize, 
  which will ensure that invoking the memoized function simultaneously 
 with 
  the same arguments will only call the underlying function once. Below 
 is a 
  quick implementation with one obvious drawback (and probably tons of 
 bugs 
  and points of improvement!), namely that if the underlying function is 
  costly, and we invoke the memoized function with a bunch of different 
  non-cached set of arguments, then calculating the values will be done 
  one-by-one. This could be fixed for example by having handle-ch 
 delegate to 
  another channel, where we have one channel per set of arguments - I'll 
 leave 
  that for someone else, or for when I've had some sleep and realized 
 what a 
  bad idea it was...  :) Note that I haven't worked much with core.async, 
 and 
  that there is probably a much more straightforward solution (for 
 example the 
  one given by Thomas Heller), so please let me know of any issues with 
 this: 
  
  
  (defn synced-memoize [f] 
(let [mem (atom {}) 
  handle-ch (chan)] 
  (go-loop [] 
(let [[args ret-ch] (! handle-ch)] 
  (! ret-ch (if-let [e (find @mem args)] 
   (val e) 
   (let [ret (apply f args)] 
 (swap! mem assoc args ret) 
 ret))) 
  (recur))) 
  (fn [ args] 
(if-let [e (find @mem args)] 
  (val e) 
  (let [ret (chan)] 
(!! handle-ch [args ret]) 
(!! ret)) 
  
  (def lookup 
(let [calc-value* (synced-memoize calc-value)] 
  (fn [cache key] 
(if (contains? @cache key) 
  (@cache key) 
  (swap! cache assoc key (calc-value* key)) 
  
  
  
  Den måndagen den 1:e september 2014 kl. 22:35:56 UTC+2 skrev Marcus 
  Magnusson: 
  
  I reckon if that worked, there would be no need for memoize anyway, 
 but I 
  don't think swap! will allow for it. I'm far from an expert on swap! 
 or 
  atoms, but several swap!s may be run simultaneously on a single atom 
 (and 
  swap! may re-run the swapping function if the atom has been changed 
 since 
  the swapping function was invoked). In other words, if two swap!s are 
  

Re: Using an atom for a caching map

2014-09-02 Thread Daniel
If the values in the map don't change then why not just drop the map? 
 Implement the map as a function and memoize it eg (def f (memoize (fn [k] 
(calc-value k

On Saturday, August 30, 2014 12:27:05 AM UTC-5, Colin Fleming wrote:

 Hi all,

 I want to use a map to cache values based on a key. I'm planning to use an 
 atom for this. My basic operation is give me the value for this key - if 
 the value exists in the map then that value should be returned, otherwise a 
 new value should be calculated, inserted in the map and then returned. My 
 plan is to implement something like the following:


 (defn ensure [cache key]  (if (contains? cache key)cache(assoc cache 
 key (calc-value key(let [value (get (swap! cache ensure key) key)]  ... 
 do my thing with value ...)


 So 'ensure' ensures that the cache contains the value for key, the swap! 
 operation returns the cache with the value and then I get it out. This 
 works but feels a little clumsy, is there a better way to do this?

 Also, looking at the Atom source code, I see that this will cause a CAS 
 operation even if the value returned from swap! is identical to the 
 original value. It seems like a reasonable optimisation would be to check 
 if the values are identical and not update if so - is there a reason this 
 might not be a good idea?

 Thanks,
 Colin


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Gorilla REPL 0.3.3 - inline docs, CIDER compatibility

2014-09-02 Thread Jony Hudson
On Tuesday, 2 September 2014 01:36:49 UTC+1, Beau Fabry wrote:

 Just a little bit of showing off of the previous post :-) 
 http://i.imgur.com/zpfP9Ja.png


Nice! Would love to hear more about how you use it. I've only tinkered with 
Hadoop locally, so I'm very fuzzy on the concepts - you need to run Gorilla 
in-process on one of the hadoop nodes, rather than connecting to hadoop 
with a client library?


Jony

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] Taoensso library updates / 2014 September

2014-09-02 Thread Peter Taoussanis
(All new releases are now on BreakVersioning, 
https://github.com/ptaoussanis/encore/blob/master/BREAK-VERSIONING.md).

*Sente - v1.0.0 / 2014 Sep 2 (today)*
*==*
*Realtime web comms for Clojure/Script (think Socket.IO but with Transit  
core.async).*
https://github.com/ptaoussanis/sente/releases
Notable recent changes: v1 release, optional Transit support, efficiency 
improvements (perf+bandwidth).

*Carmine - v2.7.0 / 2014 Aug 27 (-6days)*
*==*
*Clojure Redis client + message queue.*
https://github.com/ptaoussanis/carmine/releases
Notable recent changes: lock-free Apache Commons Pool 2 pooling, updated 
Redis commands.

*Faraday - v1.5.0 / 2014 July 26 (-38days)*
*==*
*Clojure DynamoDB client.*
https://github.com/ptaoussanis/faraday/releases
Notable recent changes: allow reading of unserialized bin values written 
with other clients.

*Nippy - v2.7.0-RC1 / 2014 Aug 27 (-6days)*
*==*
*High-performance Clojure binary serialization.*
https://github.com/ptaoussanis/nippy/releases
Notable recent changes: ~40% perf bump over v2.6.0, LZ4 compressor, id'd 
extension types, Fressian comparison benchmarks.

*Timbre - v3.3.0 / 2014 May 8 (-4months)*
*==*
*Pure-Clojure logging + profiling.*
https://github.com/ptaoussanis/timbre/releases
Recent changes: some minor fixes, appender updates.

*Tower - v3.0.0 / 2014 Aug 28 (-5days)*
*==*
*i18n and L10n library for Clojure.*
https://github.com/ptaoussanis/tower/releases
Recent changes: final ClojureScript support, a bunch of general API 
improvements.

*Touchstone - v2.0.2 / 2014 Mar 30 (-5months)*
*==*
*A/B testing for Clojure.*
https://github.com/ptaoussanis/touchstone/releases
Recent changes: stable.

*Encore - v1.7.3 / 2014 Sep 1 (yesterday)*
*==*
*General cross-platform Clojure/Script utils.*
https://github.com/ptaoussanis/encore/releases
Recent changes: nothing major- a few new utils, a few fixes.


*Useful links*
*==*
Libs on GitHub: https://github.com/ptaoussanis?tab=repositories
Libs homepage: https://www.taoensso.com/clojure-libraries
Twitter (lib announcements, etc.): https://twitter.com/ptaoussanis


As usual, please feel free to ping with any 
questions/problems/suggestions/whatever.

Happy hacking/Tuesday, cheers! :-)

-- 

*Peter Taoussanis*ptaoussanis at taoensso.com

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Gorilla REPL 0.3.3 - inline docs, CIDER compatibility

2014-09-02 Thread Beau Fabry
A client library may be another option, I haven't looked into it. Off the 
top of my head I doubt the cascalog code distribution for the m/r jobs 
would work with any clients. This is akin to deploying new code to run on 
the cluster, in this case via a repl, so I don't think any existing API is 
going to support it. You could certainly connect a client that runs PIG 
jobs or something, but that's a lot less powerful than being able to 
distribute just-defined clojure functions out to the cluster as map 
operations on the fly :-)

Sort've like the difference between being able to connect to postgres via 
odbc and run sql, and spinning up a repl inside of postgres that can 
dynamically define functions that play with the raw data

On Wednesday, September 3, 2014 12:08:52 AM UTC+10, Jony Hudson wrote:

 On Tuesday, 2 September 2014 01:36:49 UTC+1, Beau Fabry wrote:

 Just a little bit of showing off of the previous post :-) 
 http://i.imgur.com/zpfP9Ja.png


 Nice! Would love to hear more about how you use it. I've only tinkered 
 with Hadoop locally, so I'm very fuzzy on the concepts - you need to run 
 Gorilla in-process on one of the hadoop nodes, rather than connecting to 
 hadoop with a client library?


 Jony


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to use Java library from sources

2014-09-02 Thread Wilker
Hello,

I'm trying to use this Java library on my project:
https://github.com/kichik/pecoff4j

But I'm still very new to the whole ecosystem, I was looking for some way
to first convert this to a jar, and then to load this jar into my Leiningen
project, I found a few posts on internet like this one:

http://www.elangocheran.com/blog/2013/03/installing-jar-files-locally-for-leiningen-2/

But they don't cover how to build the jar from the sources in first place,
and those seem a bit old.

How is a good way for me to get the pecoff4j in my project? Another detail
is that my project is a Leiningen plugin, so I need to have this dependency
shared with the plugin users.

Thanks.
---
Wilker Lúcio
http://about.me/wilkerlucio/bio
Woboinc Consultant
+55 81 82556600

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use Java library from sources

2014-09-02 Thread adrian . medina
If you can't figure out how to build the JAR, you can try copying the Java 
source code directly into your Clojure project. Leiningen allows you to 
specify :java-source-paths in your project.clj, as seen here 
(https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L276). 
Then you can (:import (org.boris.pecoff4j SectionHeader .. other classes )) 
in your Clojure namespace declarations. 

On Tuesday, September 2, 2014 11:07:32 AM UTC-4, Wilker wrote:

 Hello,

 I'm trying to use this Java library on my project: 
 https://github.com/kichik/pecoff4j

 But I'm still very new to the whole ecosystem, I was looking for some way 
 to first convert this to a jar, and then to load this jar into my Leiningen 
 project, I found a few posts on internet like this one:


 http://www.elangocheran.com/blog/2013/03/installing-jar-files-locally-for-leiningen-2/

 But they don't cover how to build the jar from the sources in first place, 
 and those seem a bit old.

 How is a good way for me to get the pecoff4j in my project? Another detail 
 is that my project is a Leiningen plugin, so I need to have this dependency 
 shared with the plugin users.

 Thanks.
 ---
 Wilker Lúcio
 http://about.me/wilkerlucio/bio
 Woboinc Consultant
 +55 81 82556600
  

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


HTTP server that supports ring handlers, but asynchronously?

2014-09-02 Thread Laurens Van Houtven
Hi,


I'm writing a pretty simple HTTPS API that, when you make a request to it, 
it makes a bunch of requests on your behalf, and eventually reports success 
or failure. Because it makes many requests with a bunch of interaction 
between them, I'd really like to use core.async. Internally (that is, until 
it hit the HTTP server API), it's a channel with a bunch of maps on it that 
eventually closes when it's done. I can write the code to turn this 
bunch-of-maps into a suitable response map, but the hard part seems to be 
getting HTTP servers to accept a channel instead of a synchronous response.

I started with ring and a bunch of middleware, but ring seems to really 
want me to return a request map synchronously. I guess the API that I'd 
ideally want is something just like a ring handler (and that works with 
ring middleware), but instead lets me return a (core.async) channel. That 
channel would probably just return a single response map and close.

I was already using http-kit for the asynchronous client, so I started with 
using it as the server as well. Unfortunately it does not appear to support 
the API above. The async server API is this long-polling/websockety thing 
that lets me pipe in some data (which is ignored by middleware), but I do 
really want simple HTTP(S) request/response pairs. Just lots of them :-)

Doing take!! off that channel with the request-map might work, but probably 
isn't the best idea in terms of concurrency.


thanks in advance for your suggestions,
lvh

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Useless Java error messages

2014-09-02 Thread John Gabriele
On Monday, September 1, 2014 7:24:54 PM UTC-4, Beau Fabry wrote:

 The pretty-errors leiningen plugin might be worth a look


Hm... I don't see that particular plug-in in the [main lein plug-in 
list](https://github.com/technomancy/leiningen/wiki/Plugins).

Do you mean [clj-stacktrace](https://github.com/mmcgrana/clj-stacktrace)? 
(not a lein plug-in)

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: HTTP server that supports ring handlers, but asynchronously?

2014-09-02 Thread James Reeves
Ring uses blocking I/O by default, because that's often sufficient for most
web servers, and is generally easier to reason about. HTTP works best when
the response is returned ASAP, which means blocking I/O typically isn't
much of a bottleneck.

However, since Ring 1.2, all of the standard middleware has also been
available to use asynchronously, in order to support frameworks like
Pedestal. So it's certainly possible to use Ring in an async environment,
at least with the core Ring libs.

Although HTTP Kit doesn't use core.async channels itself, the async
protocol used isn't complex. You should be able to hook up core.async/take!
to http-kit/send!. Something like:

(defn handler [req]
  (httpkit/with-channel req http-ch
(let [resp-ch (async-handler! req)]
  (httpkit/on-close (fn [_] (a/close! resp-ch)))
  (a/take! resp-ch (fn [resp] (httpkit/send! http-ch resp)
(httpkit/close http-ch))

That said, I'd be wary about having HTTP clients wait around on the server.
If it's just a few seconds, that seems reasonable, but any longer and you
should consider redirecting to a job resource instead.

- James



On 2 September 2014 16:41, Laurens Van Houtven _...@lvh.cc wrote:

 Hi,


 I'm writing a pretty simple HTTPS API that, when you make a request to it,
 it makes a bunch of requests on your behalf, and eventually reports success
 or failure. Because it makes many requests with a bunch of interaction
 between them, I'd really like to use core.async. Internally (that is, until
 it hit the HTTP server API), it's a channel with a bunch of maps on it that
 eventually closes when it's done. I can write the code to turn this
 bunch-of-maps into a suitable response map, but the hard part seems to be
 getting HTTP servers to accept a channel instead of a synchronous response.

 I started with ring and a bunch of middleware, but ring seems to really
 want me to return a request map synchronously. I guess the API that I'd
 ideally want is something just like a ring handler (and that works with
 ring middleware), but instead lets me return a (core.async) channel. That
 channel would probably just return a single response map and close.

 I was already using http-kit for the asynchronous client, so I started
 with using it as the server as well. Unfortunately it does not appear to
 support the API above. The async server API is this long-polling/websockety
 thing that lets me pipe in some data (which is ignored by middleware), but
 I do really want simple HTTP(S) request/response pairs. Just lots of them
 :-)

 Doing take!! off that channel with the request-map might work, but
 probably isn't the best idea in terms of concurrency.


 thanks in advance for your suggestions,
 lvh

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use Java library from sources

2014-09-02 Thread Jony Hudson
I think if you're going to distribute a Leiningen plugin then you'll either 
need to publish pecoff4j to maven/clojars, or include the source in your 
build.


Jony


On Tuesday, 2 September 2014 16:07:32 UTC+1, Wilker wrote:

 Hello,

 I'm trying to use this Java library on my project: 
 https://github.com/kichik/pecoff4j

 But I'm still very new to the whole ecosystem, I was looking for some way 
 to first convert this to a jar, and then to load this jar into my Leiningen 
 project, I found a few posts on internet like this one:


 http://www.elangocheran.com/blog/2013/03/installing-jar-files-locally-for-leiningen-2/

 But they don't cover how to build the jar from the sources in first place, 
 and those seem a bit old.

 How is a good way for me to get the pecoff4j in my project? Another detail 
 is that my project is a Leiningen plugin, so I need to have this dependency 
 shared with the plugin users.

 Thanks.
 ---
 Wilker Lúcio
 http://about.me/wilkerlucio/bio
 Woboinc Consultant
 +55 81 82556600
  

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


core.async take behaviour

2014-09-02 Thread cig
Hi

I was expecting the following example to park, waiting for the 'out' 
channel to be cleared. Could anybody explain why 'take' does not
park when the output buffer size is smaller than the number of entries 
being taken from the input channel?

(def from (to-chan [1 2 3 4 5 6 7]))
(!! (into [] (take 4 from *2*)))   ;; note: the output channel buffer 
size is 2 (less than 4 items being taken off of the 'from' channel)

;; = [1 2 3 4]


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: core.async take behaviour

2014-09-02 Thread Timothy Baldridge
It's because into is pulling items as fast as it can from take. Sure the
buffer might get full but then into takes another value allowing take to
continue.

Timothy


On Tue, Sep 2, 2014 at 1:48 PM, cig clifford.goldb...@gmail.com wrote:

 Hi

 I was expecting the following example to park, waiting for the 'out'
 channel to be cleared. Could anybody explain why 'take' does not
 park when the output buffer size is smaller than the number of entries
 being taken from the input channel?

 (def from (to-chan [1 2 3 4 5 6 7]))
 (!! (into [] (take 4 from *2*)))   ;; note: the output channel
 buffer size is 2 (less than 4 items being taken off of the 'from' channel)

 ;; = [1 2 3 4]


  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Useless Java error messages

2014-09-02 Thread Beau Fabry
apologies, not a leiningen plugin. https://github.com/AvisoNovate/pretty

On Wednesday, September 3, 2014 2:17:21 AM UTC+10, John Gabriele wrote:

 On Monday, September 1, 2014 7:24:54 PM UTC-4, Beau Fabry wrote:

 The pretty-errors leiningen plugin might be worth a look


 Hm... I don't see that particular plug-in in the [main lein plug-in list](
 https://github.com/technomancy/leiningen/wiki/Plugins).

 Do you mean [clj-stacktrace](https://github.com/mmcgrana/clj-stacktrace)? 
 (not a lein plug-in)



-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Taoensso library updates / 2014 September

2014-09-02 Thread Sun Ning

Good job! I will adapt Nippy 2.7.0 in my projects soon.

On 09/02/2014 10:28 PM, Peter Taoussanis wrote:
(All new releases are now on BreakVersioning, 
https://github.com/ptaoussanis/encore/blob/master/BREAK-VERSIONING.md).


*Sente - v1.0.0 / 2014 Sep 2 (today)*
*==*
/Realtime web comms for Clojure/Script (think Socket.IO but with 
Transit  core.async)./
https://github.com/ptaoussanis/sente/releases 
https://github.com/ptaoussanis/sente/releases
Notable recent changes: v1 release, optional Transit support, 
efficiency improvements (perf+bandwidth).


*Carmine - v2.7.0 / 2014 Aug 27 (-6days)*
*==*
/Clojure Redis client + message queue./
https://github.com/ptaoussanis/carmine/releases 
https://github.com/ptaoussanis/carmine/releases
Notable recent changes: lock-free Apache Commons Pool 2 pooling, 
updated Redis commands.


*Faraday - v1.5.0 / 2014 July 26 (-38days)*
*==*
/Clojure DynamoDB client./
https://github.com/ptaoussanis/faraday/releases 
https://github.com/ptaoussanis/faraday/releases
Notable recent changes: allow reading of unserialized bin values 
written with other clients.


*Nippy - v2.7.0-RC1 / 2014 Aug 27 (-6days)*
*==*
/High-performance Clojure binary serialization./
https://github.com/ptaoussanis/nippy/releases 
https://github.com/ptaoussanis/nippy/releases
Notable recent changes: ~40% perf bump over v2.6.0, LZ4 compressor, 
id'd extension types, Fressian comparison benchmarks.


*Timbre - v3.3.0 / 2014 May 8 (-4months)*
*==*
/Pure-Clojure logging + profiling./
https://github.com/ptaoussanis/timbre/releases 
https://github.com/ptaoussanis/timbre/releases

Recent changes: some minor fixes, appender updates.

*Tower - v3.0.0 / 2014 Aug 28 (-5days)*
*==*
/i18n and L10n library for Clojure./
https://github.com/ptaoussanis/tower/releases 
https://github.com/ptaoussanis/tower/releases
Recent changes: final ClojureScript support, a bunch of general API 
improvements.


*Touchstone - v2.0.2 / 2014 Mar 30 (-5months)*
*==*
/A/B testing for Clojure./
https://github.com/ptaoussanis/touchstone/releases 
https://github.com/ptaoussanis/touchstone/releases

Recent changes: stable.

*Encore - v1.7.3 / 2014 Sep 1 (yesterday)*
*==*
/General cross-platform Clojure/Script utils./
https://github.com/ptaoussanis/encore/releases
Recent changes: nothing major- a few new utils, a few fixes.


*Useful links*
*==**
*
Libs on GitHub: https://github.com/ptaoussanis?tab=repositories 
https://github.com/ptaoussanis?tab=repositories
Libs homepage: https://www.taoensso.com/clojure-libraries 
https://www.taoensso.com/clojure-libraries
Twitter (lib announcements, etc.): https://twitter.com/ptaoussanis 
https://twitter.com/ptaoussanis



As usual, please feel free to ping with any 
questions/problems/suggestions/whatever.


Happy hacking/Tuesday, cheers! :-)

--
*Peter Taoussanis
*ptaoussanis at taoensso.com http://taoensso.com/
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient 
with your first post.

To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google 
Groups Clojure group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to clojure+unsubscr...@googlegroups.com 
mailto:clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups Clojure group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use Java library from sources

2014-09-02 Thread Wilker
Thanks guys, I'll try it out :)

---
Wilker Lúcio
http://about.me/wilkerlucio/bio
Woboinc Consultant
+55 81 82556600


On Tue, Sep 2, 2014 at 2:03 PM, Jony Hudson jonyepsi...@gmail.com wrote:

 I think if you're going to distribute a Leiningen plugin then you'll
 either need to publish pecoff4j to maven/clojars, or include the source in
 your build.


 Jony


 On Tuesday, 2 September 2014 16:07:32 UTC+1, Wilker wrote:

 Hello,

 I'm trying to use this Java library on my project: https://github.com/
 kichik/pecoff4j

 But I'm still very new to the whole ecosystem, I was looking for some way
 to first convert this to a jar, and then to load this jar into my Leiningen
 project, I found a few posts on internet like this one:

 http://www.elangocheran.com/blog/2013/03/installing-jar-
 files-locally-for-leiningen-2/

 But they don't cover how to build the jar from the sources in first
 place, and those seem a bit old.

 How is a good way for me to get the pecoff4j in my project? Another
 detail is that my project is a Leiningen plugin, so I need to have this
 dependency shared with the plugin users.

 Thanks.
 ---
 Wilker Lúcio
 http://about.me/wilkerlucio/bio
 Woboinc Consultant
 +55 81 82556600

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use Java library from sources

2014-09-02 Thread Maksim Karandashov
The best way: Write maven pom.xml for your Java project for automatically 
putting it to maven repo (local or not).
But it not always possible.

I think that the good way is it packaging extern Java code to JAR and 
putting it to local repo.
You can do it easly with some IDE (I prefer IntelliJ IDEA) and 
lein-localrepo plugin: https://github.com/kumarshantanu/lein-localrepo
In this way you don't need to use :java-source-paths (I suppose that it 
must be use only for internal java code in your project).

вторник, 2 сентября 2014 г., 19:07:32 UTC+4 пользователь Wilker написал:

 Hello,

 I'm trying to use this Java library on my project: 
 https://github.com/kichik/pecoff4j

 But I'm still very new to the whole ecosystem, I was looking for some way 
 to first convert this to a jar, and then to load this jar into my Leiningen 
 project, I found a few posts on internet like this one:


 http://www.elangocheran.com/blog/2013/03/installing-jar-files-locally-for-leiningen-2/

 But they don't cover how to build the jar from the sources in first place, 
 and those seem a bit old.

 How is a good way for me to get the pecoff4j in my project? Another detail 
 is that my project is a Leiningen plugin, so I need to have this dependency 
 shared with the plugin users.

 Thanks.
 ---
 Wilker Lúcio
 http://about.me/wilkerlucio/bio
 Woboinc Consultant
 +55 81 82556600
  

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.