Re: obtain # of elements currently on a channel?

2014-01-12 Thread Jozef Wagner
You can do it with a custom buffer and count function. user= (def b (buffer 1000)) #'user/b user= (def c (chan b)) #'user/c user= (count b) 0 user= (!! c :foo) nil user= (!! c :foo) nil user= (!! c :foo) nil user= (!! c :foo) nil user= (count b) 4 user= On Sun, Jan 12, 2014 at 3:59 AM, t x

Re: JAVA_OPTS not accessible in my Clojure project

2014-01-12 Thread aidy lewis
Hi Phil, M-x cider-jack-in, but the JAVA_OPT properties are also nil if I do a lein run. Thanks Aidy On 12 January 2014 05:25, Matching Socks phill.w...@gmail.com wrote: How did you start the Emacs Cider REPL? -- -- You received this message because you are subscribed to the Google

Type hint using protocol

2014-01-12 Thread bob
Hi, Is it possible to add type hint (the type is protocol) to funs? for example: (defprotocol IProtocol (f1 [])) can we define fn like this? (defn ftest [^IProtocol arg] (.toString arg)) -- -- You received this message because you are subscribed to the Google Groups Clojure group. To

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
In order to do that you would have to reach to the interface behind the protocol...observer this: user= (defprotocol P (f1 [_] nil)) P user= P {:on-interface user.P, :on user.P, :sigs {:f1 {:doc YES!, :arglists ([_]), :name f1}}, :var #'user/P, :method-map {:f1 :f1}, :method-builders

Re: Type hint using protocol

2014-01-12 Thread bob
Exactly! the compiler throws the reflection warnings, I want to type hint for the input parameters to eliminate the warnings. On Sunday, January 12, 2014 8:58:14 PM UTC+8, Jim foo.bar wrote: In order to do that you would have to reach to the interface behind the protocol...observer this:

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
On 12/01/14 13:04, bob wrote: Exactly! the compiler throws the reflection warnings, I want to type hint for the input parameters to eliminate the warnings. you must be doing something wrong as a pure protocol based implementation that doesn't involve interop, shouldn't exhibit

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
On 12/01/14 13:07, Jim - FooBar(); wrote: On 12/01/14 13:04, bob wrote: Exactly! the compiler throws the reflection warnings, I want to type hint for the input parameters to eliminate the warnings. you must be doing something wrong as a pure protocol based implementation that doesn't

Re: Type hint using protocol

2014-01-12 Thread bob
Sure, here has a protocol named Storehttps://github.com/weejulius/raiseup/blob/master/diy/raiseup/src/cqrs/storage.clj , and will be used in this filehttps://github.com/weejulius/raiseup/blob/master/diy/raiseup/src/cqrs/eventstore.clj at line #14, the compiler tells me the warnings, forgot

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
Haha I knew it Instead of using .ret-value and .write use cqrs.storage/ret-value and cqrs.storage/write...Also in your ns declaration you don't really need to bring in the protocol. YOu can bring in the functions it defines :) Jim On 12/01/14 13:22, bob wrote: Sure, here has a

Re: Type hint using protocol

2014-01-12 Thread bob
If I remove the dot, it cannot be compiled. can you give an example? On Sunday, January 12, 2014 9:22:00 PM UTC+8, Jim foo.bar wrote: I am suspecting you are calling the protocol implementations via the `.` form, whereas you should be going via the protocol itself (whatever namespace that

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
Basically you're falling into the trap of thinking of protocols as if they were interfaces...protocols do not represent a specific data-type but rather a contract. That contract can then be extended to any concrete type. But you always need to go through the protocol...what I do when I have

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
It is not compiling because it cannot find the function...either fully qualify it like in my previous email or change your ns declaration to something like: [cqrs.storage :as stora] and then simply use stora/ret-value, stora/write, stora/write-batch Jim On 12/01/14 13:26, bob wrote: If I

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
there you go: (defprotocol IBark (bark [this])) (in-ns 'other) (set! user/*warn-on-reflection* true) (clojure.core/defrecord Dog [] user/IBark (bark [_] (clojure.core/println WOOF!))) (def d (Dog.)) (user/bark d) ;;NO reflection (.bark d) ;;reflection it should be obvious now :) Jim

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
oops (set! *clojure.core*/*warn-on-reflection* true) instead of (set! *user*/*warn-on-reflection* true) On 12/01/14 13:52, Jim - FooBar(); wrote: there you go: (defprotocol IBark (bark [this])) (in-ns 'other) (set! user/*warn-on-reflection* true) (clojure.core/defrecord Dog []

Re: Type hint using protocol

2014-01-12 Thread bob
Thanks for the big help, I treated the protocol as interface. :) On Sunday, January 12, 2014 9:38:12 PM UTC+8, Jim foo.bar wrote: It is not compiling because it cannot find the function...either fully qualify it like in my previous email or change your ns declaration to something like:

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
On 12/01/14 13:57, bob wrote: Thanks for the big help, I treated the protocol as interface. :) no worries :) I was also surprised to see that you are type-hinting the clojure.lang.Atom...why would you do that? from what I can see you are only using `reset!` and `swap!`...I doubt that you are

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
On 12/01/14 13:59, Jim - FooBar(); wrote: On 12/01/14 13:57, bob wrote: Thanks for the big help, I treated the protocol as interface. :) no worries :) I was also surprised to see that you are type-hinting the clojure.lang.Atom...why would you do that? from what I can see you are only using

Re: Type hint using protocol

2014-01-12 Thread Jim - FooBar();
On 12/01/14 14:15, Jim - FooBar(); wrote: (map [this f] (let [^DBIterator iterator (.iterator db)] (.seekToFirst iterator) (clojure.core/map #(apply f %) (iterator-seq iterator or even nicer: (map [this f] (let [^DBIterator iterator (doto (.iterator db) .seekToFirst)]

Re: JAVA_OPTS not accessible in my Clojure project

2014-01-12 Thread dennis zhuang
Tried System/getenv ? 2014/1/12 aidy lewis aidy.le...@gmail.com Hi Phil, M-x cider-jack-in, but the JAVA_OPT properties are also nil if I do a lein run. Thanks Aidy On 12 January 2014 05:25, Matching Socks phill.w...@gmail.com wrote: How did you start the Emacs Cider REPL? --

Re: Type hint using protocol

2014-01-12 Thread bob
Cool! learn a lot from you. thanks again. On Sunday, January 12, 2014 10:22:30 PM UTC+8, Jim foo.bar wrote: or even nicer: (map [this f] (let [^DBIterator iterator (doto (.iterator db) .seekToFirst)] (clojure.core/map #(apply f %) (iterator-seq iterator Ok I will stop now! :)

Re: Nginx-Clojure Let You Deploy Clojure Web App on Nginx Without Any Java Web Server

2014-01-12 Thread Xfeep Zhang
Sorry for my mistake! 1. In the static file test, the result is about 10 concurrents. NOT 1 concurrents (Concurrency Level: 10 in the ab report ). 2. In the small string test, All results about three server are about 10 concurrents. NOT 1 concurrents. There are right results

ANN Langohr 2.2.0 is released

2014-01-12 Thread Michael Klishin
Langohr [1] is a small, feature complete Clojure client for RabbitMQ. Release notes: http://blog.clojurewerkz.org/blog/2014/01/10/langohr-2-dot-2-0-is-released/ 1. http://clojurerabbitmq.info -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- You received this

Re: Nginx-Clojure Let You Deploy Clojure Web App on Nginx Without Any Java Web Server

2014-01-12 Thread Xfeep Zhang
Sorry for my mistake! 1. In the static file test, the ring-jetty result is about 10 concurrents. NOT 1 concurrents (Concurrency Level: 10 in the ab report ). 2. In the small string test, All results about three server are about 10 concurrents. NOT 1 concurrents. There are right

Re: [ANN] dynalint 0.1.0

2014-01-12 Thread Ambrose Bonnaire-Sergeant
Hi everyone, Please try [lein-dynalint 0.1.1]. You should be able to specify a file to dump the verbose warnings like: lein dynalint test :output my-name-name Please give it a shot. Thanks, Ambrose On Sun, Jan 12, 2014 at 1:04 AM, Eric Normand ericwnorm...@gmail.comwrote: Hi Ambrose,

Re: JAVA_OPTS not accessible in my Clojure project

2014-01-12 Thread Matching Socks
The Leiningen sample project https://github.com/technomancy/leiningen/blob/master/sample.project.clj refers to a :jvm-opts key and a JVM_OPTS environment variable. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Managing role-based permissions in Ring apps

2014-01-12 Thread Alexandr Kurilin
My Ring app is undergoing growing pains: I think I need some kind of abstraction for managing user permissions when working with my RDBMS. Our system has few user roles and they all own or have rights to a bunch of data in a hierarchical fashion e.g. admin manager employee etc. So far I've

Adding query customization to Ring-based REST APIs

2014-01-12 Thread Alexandr Kurilin
I'm investigating adding query options to my Ring app's GET requests for the more boring CRUD routes. I'd like to allow the caller to specify a set of SQL-level query customizations such as sorting, paging, counting, distinct ons, limits, some basic constraints etc. across all of my resources,

Re: Managing role-based permissions in Ring apps

2014-01-12 Thread Sam Ritchie
cemerick's Friend library is the way to do this: https://github.com/cemerick/friend I'm writing up a post on how to combine Friend with Liberator, for easy ACL management for RESTful APIs. Take a look and let us know what you think! Alexandr Kurilin mailto:a...@kurilin.net January 12, 2014

Re: Nginx-Clojure Let You Deploy Clojure Web App on Nginx Without Any Java Web Server

2014-01-12 Thread Xfeep Zhang
So far I have found why nginx-clojure is slower than http-kit when 1 concurrents. (when = 1000 concurrents nginx-clojure is faster than http-kit.) I have set too many connections per nginx worker (worker_connections = 2) . This make nginx only use one worker to handle ab requests

Re: Clojure web server benchmarks

2014-01-12 Thread Xfeep Zhang
If reduce worker_connections from 2 to 1024 or 128, I think nignx will be the fastest one in this test (the max concurrent level is only 96). On Saturday, January 5, 2013 11:52:57 PM UTC+8, Peter Taoussanis wrote: Hi all, Quick post to mention that I've put up some rough benchmarks

Am I using core.async/go in an un-clojurish ?

2014-01-12 Thread t x
Hi, Some claim that one superficial aspect of good clojure code is: * defining short functions that can be composed However, go-blocks seems to go against this paradigm. Consider the following: (go (loop [ ... ] (case ... .. (... ! ... ) .. (... ! ... )

Re: Clojure web server benchmarks

2014-01-12 Thread Peter Taoussanis
Hi Xfeep, Thank you, I could never understand what configuration (setting) was wrong. I do not have time to update the project now, but if you give me your GitHub user name - I can add you to the repo? You can update the tests and/or results if you want to. Thank you also for your work on

Re: Clojure web server benchmarks

2014-01-12 Thread Xfeep Zhang
In this test there are other problems which maybe unfriendly to Nginx. (1) Nginx will read the file from DISK for EVERY request. Again the sendfile is disabled. Worse! Although OS will cahed this file but KERNEL - Nginx Process Space will still cost a lot. (2) Both Ring-Jetty and Http-kit

Re: Clojure web server benchmarks

2014-01-12 Thread Xfeep Zhang
You are welcome. My Github user name is xfeep. I'm glad to join the repo. Thanks for your invitation! On Monday, January 13, 2014 2:42:44 PM UTC+8, Peter Taoussanis wrote: Hi Xfeep, Thank you, I could never understand what configuration (setting) was wrong. I do not have time to update

Re: Adding query customization to Ring-based REST APIs

2014-01-12 Thread Jan Herich
Hello Alexander, I did some work in this area some time ago, and the result was service-hub library https://github.com/ITEdge/service-hub - created to simplify basic CRUD services. It's designed to allow more then one type of data-store, currently it supports SQL databases (i use my own fork

Re: Clojure web server benchmarks

2014-01-12 Thread Peter Taoussanis
You are welcome. My Github user name is xfeep. I'm glad to join the repo. Thanks for your invitation! Okay, great - I have added you. You can make any changes you like. I would be happy if you or someone else wants to maintain (update) the repo. Cheers :-) -- *Peter Taoussanis* -- --

Re: Managing role-based permissions in Ring apps

2014-01-12 Thread Stefan Kamphausen
On Monday, January 13, 2014 3:53:43 AM UTC+1, Sam Ritchie wrote: cemerick's Friend library is the way to do this: https://github.com/cemerick/friend I'm writing up a post on how to combine Friend with Liberator, for easy ACL management for RESTful APIs. Take a look and let us know what