Ananto30 / zero

Zero: A simple and fast Python RPC framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Registering object method

trollfot opened this issue · comments

Hello. First of all, thank you for this project that solves a lot of problems I had, using 0MQ.

I'd like to know if it's possible to register object methods as RPC endpoint.

It seems the fact that the signature enforces a single arg prevents this (self gets in the way)
Am I the only one with this kind of need ? Would it be a welcome addition ?

Thank you

I proposed a pull request that would simplify things, using inspect.signature. The method registration comes free with it. #27

Thank you @trollfot for the suggestion and the PR.

But the main idea is you actually cannot register object methods that easily until we provide a "base class" and you extend from it. Otherwise, you can have the same name for different instances, solely the register method cannot understand that because it keeps track with just a dict.

So the simplest solution can be a base "ZeroRPC" class and any method under it will be registered with the instance pointer.

Currently, I don't have a plan for it because if you see most of the Python frameworks only support function registers (mostly with annotation, I have a plan to add that).