Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registering object method #26

Open
trollfot opened this issue Mar 17, 2023 · 3 comments
Open

Registering object method #26

trollfot opened this issue Mar 17, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@trollfot
Copy link

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

@trollfot
Copy link
Author

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

@Ananto30
Copy link
Owner

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).

@Ananto30 Ananto30 added the enhancement New feature or request label Mar 26, 2023
@wanglong001
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants