[IPython-dev] messaging protocol

Jason Grout jason-sage at creativetrax.com
Thu Apr 7 21:27:09 EDT 2011


I've been pondering the messaging spec quite a bit over the last few 
weeks and meshing it in with a project in Sage (a single-cell server, 
like a one-off ipython or sage web notebook).  Our architecture is that 
we have a big database sitting on the server side that basically acts as 
a cache of the zeromq messages between the kernel and the web client. It 
is easy enough to store the messages in the database, but we have a 
problem that you guys don't have since you use zeromq end-to-end.  Once 
we put a list of messages into the database, we don't know what the 
right order for the messages is.  So here is a 
suggestion/request/proposal for the API:

PROPOSAL: Can we add another field to the header of a, a msg_order (or 
msg_counter?) field, which (across messages with the same 
header['session']) is guaranteed to be an increasing integer signifying 
the order of messages?

You might ask why we don't just use the msg_id field for this.  Well, it 
seems nice for us to make the msg_id be a mongodb id object, which is 
just a hash.  It seems elegant to let the client or server dictate what 
how the msg_id's are formed with no insistence on a particular format or 
structure for the msg_id, other than it be unique among messages in the 
same session.

You must have had a related problem storing history, though.  How did 
you sort the messages in the history database?

On the other hand, since the proposed msg_order *is* guaranteed to be 
unique across all messages in a session, maybe there's nothing lost in 
(just us?) insisting that the msg_id be an increasing integer sequence.

Thanks,

Jason

--
Jason Grout




More information about the IPython-dev mailing list