I'm trying to make my service code as minimal as possible. One thing I've
noticed is that my handling of RpcProxy call replies is a bit repetitive.
So, I have a service which uses an RpcProxy to call another. The reply
arrives as a JSON string. In my service code, I'm having to turn that into
a dict, then use Bunch to make it into a class with attributes.
How would I go about putting that boilerplate stuff into a custom RpcProxy?
The implementation of the RpcProxy is bit messy. The AMQP message is
handled by the ReplyListener [1] and passed via an Eventlet Event into an
RpcReply [2], the `.result()` of which is ultimately returned to the
service.
In order to bake this transformation into the chain somewhere, you'd need
to subclass the RpcReply, which unfortunately means you also need
subclasses of MethodProxy, ServiceProxy and RpcProxy because it's not
otherwise patchable.
Two bits of good news though:
1. This sounds more like a serialisation problem. Can you implement a
custom serialiser (see [3]) that returns your Bunched object?
2. My fork has a refactor that does away with the long
MethodProxy chain and makes it easier to extend the
On Sunday, February 11, 2018 at 8:01:40 PM UTC, Chris Platts wrote:
Hi,
I'm trying to make my service code as minimal as possible. One thing I've
noticed is that my handling of RpcProxy call replies is a bit repetitive.
So, I have a service which uses an RpcProxy to call another. The reply
arrives as a JSON string. In my service code, I'm having to turn that into
a dict, then use Bunch to make it into a class with attributes.
How would I go about putting that boilerplate stuff into a custom RpcProxy?
Excellent -- a custom serialiser is a great idea -- much cleaner than
monkeying around with the message chain. I'll give it a go now (and I've
switched to Box which looks like a worthy Bunch successor).