[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] A patch for evrpc, allowing extra argument of request_new and reply_new



Hi,

I am trying to implement google protocol buffers rpc on top of  libevent2 rpc.
http://code.google.com/p/evproto
// Not finishing yet.

Now each message defined in YYY.rpc has its own XXX_new function for
malloc'ing and initializing the struct.
The function addresses are kept in in 'struct evrpc':

struct evrpc {
        /* creates a new request structure */
        void *(*request_new)(void);

        /* creates a new reply structure */
        void *(*reply_new)(void);
}

If we add an extra 'void*' argument to each of these functions,
libevent2 rpc could be easily integrated with google protocol buffers.

struct evrpc {
        /* creates a new request structure */
!        void *(*request_new)(void *);
+        void *request_new_arg;

        /* creates a new reply structure */
!        void *(*reply_new)(void *);
+        void *reply_new_arg;
}

We don't have to write a protocol buffer compiler plug-in for
generating libevent2 specific backend code, but simply sub-classing
protobuf::RpcChannel and protobuf::RpcController, and overriding
some virtual functions would do the work.

I've made a patch file, which updates other parts as well.

http://evproto.googlecode.com/svn/trunk/libevent-2.0.4-alpha-protobuf-rpc.patch

It passes regression test, and doesn't break the current usage I think,
just to rerun event_rpcgen.py and recompile the code.

Is it possible to make it official ?

Regards,
Shuo Chen
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.