librelist archives

« back to archive

Did I Miss Any Languages?

Did I Miss Any Languages?

From:
Zed A. Shaw
Date:
2011-02-09 @ 22:51
Hey everyone, I updated the web site with the latest libraries by
people:

http://mongrel2.org/

And I'm just wondering if I missed anyone?

-- 
Zed A. Shaw
http://zedshaw.com/

Re: [mongrel2] Did I Miss Any Languages?

From:
Nicolas Martyanoff
Date:
2011-02-10 @ 07:14
"Zed A. Shaw" <zedshaw@zedshaw.com> writes:

> Hey everyone, I updated the web site with the latest libraries by
> people:
>
> http://mongrel2.org/
>
> And I'm just wondering if I missed anyone?

I wrote a Common Lisp mongrel2 handler (https://github.com/galdor/m2cl)
that I use for a personnal project.

Regards,

-- 
Nicolas Martyanoff
   http://codemore.org
   khaelin@gmail.com

Re: [mongrel2] Did I Miss Any Languages?

From:
Armando Singer
Date:
2011-02-10 @ 00:37
> Hey everyone, I updated the web site with the latest libraries by
> people:
> 
> http://mongrel2.org/
> 
> And I'm just wondering if I missed anyone?

I sent out a Java Mongrel2 Handler implementation. (Original Email 
reproduced below). Someone had asked about the license--I have since added
the Apache 2 license to the handler.

Hi,

I've implemented a Java Mongrel2 Handler:

http://www.paperculture.com/code/java-mongrel2-handler.html

It's the same object model as the reference Python handler but the 
accessors are named in the java convention with getX (getSender(), etc). 
Some implementation notes:

- All objects (Request and Connection instances) are deeply immutable
- It should be impossible to get a null from any accessor, so there's no 
need to check for null when iterating over maps, arrays, or checking if 
strings are empty
- It should be impossible to construct an invalid request or connection. 
The constructors enforce preconditions.
- The 0mq messages are parsed from the raw byte[] to prevent unnecessary 
copying and encoding to a java String, which is not ascii as in some other
languages. Requests and replies can be sent/received as either byte[] or 
java Strings. Care is taken to encode/decode properly to ascii.

The requisite sample chat backend that uses the Handler impl is also 
included at the bottom of the page.

Feedback is welcome!

Cheers,
Armando

Example usage:

public final class Chat {

 private static final String SENDER_ID = "82209006-86FF-4982-B5EA-D1E29E55D481";
 private static final Connection CONN = Handler.connection(SENDER_ID,
   "tcp://127.0.0.1:9999", "tcp://127.0.0.1:9998");
 private static final ConcurrentMap<String, Object> USERS = 
Maps.newConcurrentMap();

 public static void main(String[] args) {

   for (;;) {
     final Request req = CONN.recvJson();

     final Map<String, Object> data = req.getData();
     final Object type = data.get("type");
     if ("join".equals(type)) {
       CONN.deliverJson(req.getSender(), USERS.keySet(), data);
       USERS.put(req.getConnId(), data.get("user"));
       CONN.replyJson(req, ImmutableMap.of(
         "type", "userList",
         "users", USERS.values()
       ));
     } else if ("disconnect".equals(type)) {
       System.out.println("DISCONNECTED" + req.getConnId());
       final Object removedUser = USERS.remove(req.getConnId());
       final Map<String, Object> updateData = Maps.newLinkedHashMap(data);
       updateData.put("user", removedUser);
       CONN.deliverJson(req.getSender(), USERS.keySet(), updateData);
     } else if (!USERS.containsKey(req.getConnId())) {
       USERS.put(req.getConnId(), data.get("user"));
     } else if ("msg".equals(type)) {
       CONN.deliverJson(req.getSender(), USERS.keySet(), data);
     }

     System.out.println("REGISTERED USERS: " + USERS.size());
   }
 }
}

Re: [mongrel2] Did I Miss Any Languages?

From:
Ryan Kelly
Date:
2011-02-09 @ 23:08
On Wed, 2011-02-09 at 14:51 -0800, Zed A. Shaw wrote:
> Hey everyone, I updated the web site with the latest libraries by
> people:
> 
> http://mongrel2.org/
> 
> And I'm just wondering if I missed anyone?


There are two other python libraries that might be worth listing, unless
it starts to crowd out the page too much:

  https://bitbucket.org/dholth/mongrel2_wsgi
  https://github.com/rfk/m2wsgi/


  Cheers,

     Ryan



-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
ryan@rfk.id.au        |  http://www.rfk.id.au/ramblings/gpg/ for details

Re: [mongrel2] Did I Miss Any Languages?

From:
James Dennis
Date:
2011-02-09 @ 23:14
I have done work adding web.py / tornado style routing to a coroutine
based zmq consumer.

I call it Brubeck: https://github.com/j2labs/brubeck

See the demo for what a coder would write:
https://github.com/j2labs/brubeck/blob/master/demo.py

Docs are still sparse. Actively working on it though.

I also wrote a proof of concept, before Brubeck, that might be useful
for people learning about writing handlers for m2 in python. That's
called MongrEvent. It also uses eventlet coroutines and has much
better documentation.

https://github.com/j2labs/mongrevent



On Feb 9, 2011, at 6:08 PM, Ryan Kelly <ryan@rfk.id.au> wrote:

> On Wed, 2011-02-09 at 14:51 -0800, Zed A. Shaw wrote:
>> Hey everyone, I updated the web site with the latest libraries by
>> people:
>>
>> http://mongrel2.org/
>>
>> And I'm just wondering if I missed anyone?
>
>
> There are two other python libraries that might be worth listing, unless
> it starts to crowd out the page too much:
>
>  https://bitbucket.org/dholth/mongrel2_wsgi
>  https://github.com/rfk/m2wsgi/
>
>
>  Cheers,
>
>     Ryan
>
>
>
> --
> Ryan Kelly
> http://www.rfk.id.au  |  This message is digitally signed. Please visit
> ryan@rfk.id.au        |  http://www.rfk.id.au/ramblings/gpg/ for details
>

Re: [mongrel2] Did I Miss Any Languages?

From:
Daniel Huckstep
Date:
2011-02-09 @ 22:56
I hacked up https://github.com/darkhelmet/node-mongrel2 for nodejs, but it's
kind of sketchy right now.

It requires zeromq 2.1.x which requires node 0.3.x (unstable), and there
isn't really a consistent interface for "web" stuff on node yet (like rack
or wsgi), so it has it's own little garbage interface. But it works! Sort of
:)

- Daniel

On Wed, Feb 9, 2011 at 3:51 PM, Zed A. Shaw <zedshaw@zedshaw.com> wrote:

> Hey everyone, I updated the web site with the latest libraries by
> people:
>
> http://mongrel2.org/
>
> And I'm just wondering if I missed anyone?
>
> --
> Zed A. Shaw
> http://zedshaw.com/
>