| Total Complexity | 1 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import typing |
||
| 2 | |||
| 3 | from .protocol import JsonRpcMethod |
||
| 4 | from .server import JsonRpcServer, rpc_server as default_rpc_server |
||
| 5 | |||
| 6 | |||
| 7 | __all__ = ( |
||
| 8 | 'rpc_method', |
||
| 9 | ) |
||
| 10 | |||
| 11 | |||
| 12 | def rpc_method(prefix: str = '', *, |
||
| 13 | rpc_server: JsonRpcServer = default_rpc_server, |
||
| 14 | custom_name: typing.Optional[str] = None, |
||
| 15 | add_extra_args: bool = True) -> typing.Callable: |
||
| 16 | def _decorator(func: typing.Callable) -> typing.Callable: |
||
| 17 | method = JsonRpcMethod( |
||
| 18 | prefix=prefix, |
||
| 19 | func=func, |
||
| 20 | custom_name=custom_name, |
||
| 21 | add_extra_args=add_extra_args, |
||
| 22 | ) |
||
| 23 | rpc_server.add_method(method) |
||
| 24 | return func |
||
| 25 | |||
| 26 | return _decorator |
||
| 27 |