Skip to content

Comments

feat(jsonrpc): use func name for jsonrpc method by default#90

Merged
Tishka17 merged 2 commits intoreagento:developfrom
ApostolFet:feat/jsonrpc-method-from-func-name
Dec 7, 2025
Merged

feat(jsonrpc): use func name for jsonrpc method by default#90
Tishka17 merged 2 commits intoreagento:developfrom
ApostolFet:feat/jsonrpc-method-from-func-name

Conversation

@ApostolFet
Copy link
Contributor

@ApostolFet ApostolFet commented Dec 6, 2025

We use the function name for the method if it's not explicitly specified.
For example, we currently support the following interface:

    class Api:
        @jsonrpc  # jsonrpc_method = 'do'
        def do(self, data: int) -> Model:...

        @jsonrpc()  # jsonrpc_method = 'work'
        def work(self, data: int) -> Model:...   
        
        @jsonrpc(req_transformer, res_transformer, url="/bar")  # jsonrpc_method = 'send'
        def send(self, data: int) -> Model:...   
        
        @jsonrpc('other_method', req_transformer, res_transformer)  # jsonrpc_method = 'other_method'
        def some_method(self, data: int) -> Model:...  

@ApostolFet ApostolFet force-pushed the feat/jsonrpc-method-from-func-name branch from be84136 to 143138e Compare December 6, 2025 13:14
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 6, 2025

return instance.with_params(
JsonRPCMethod(func_or_parameter),
)
elif isinstance(func_or_parameter, Transformer):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it break an order of tranformers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, new transformers are added at the beginning, and this is the very first transformer:

    def with_params(
        self,
        *transformers: Transformer,
        **params: Unpack[BuilderParams],
    ) -> "JsonRPCBuilder":
        return JsonRPCBuilder(
            *transformers,
            *self.transformers,
            **(self.params | params),
        )

@Tishka17 Tishka17 merged commit 7aa4da1 into reagento:develop Dec 7, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants