explodinglabs / jsonrpcserver

Process incoming JSON-RPC requests in Python
https://www.jsonrpcserver.com
MIT License
185 stars 40 forks source link

More high-level tools #266

Closed hovi closed 1 year ago

hovi commented 1 year ago

This library seems like solid foundation, to avoid too much boilerplate, I would like to do things like:

Basically what I have is interface that I want to be used over json-rpc and to create json-rpc client and server as simply as possible without much boilerplate code as there will be more interfaces like that. Is this anything you see as useful in this library (and it's client part)?

I will also probably add other transport methods (so far I found in the code only "serve", which does simple HTTP). I may possibly add TCP or intergrate with django routing depending on what will we require for our use-cases. Happy to make some PRs.

bcb commented 1 year ago

Hi @hovi , interesting suggestions, I'll respond to each:

  1. Decorator that runs some method using try-except and then automatically wraps the results in Success or Error

If I'm understanding correctly, the library already works like that - it gives an Error response for any unhandled exception raised in the method.

  1. Decorator similar to @method that can be used on class that will then automatically add all class method to dispatcher

There is a methods param passed to dispatch I think would help with this. Better to use a dict than using OOP in my opinion.

  1. Add other transport methods

We've had transport frameworks in the past but removed them for reasons:

jsonrpcserver is just dispatch - that's it. It can be used with any framework and the user has control.

Having said that, there's no reason another library can't build on jsonrpcserver, using it as a dependency.