aditya0yadav commented on code in PR #51:
URL: https://github.com/apache/dubbo-python/pull/51#discussion_r2197647167


##########
src/dubbo/client.py:
##########
@@ -84,68 +86,274 @@ def _initialize(self):
 
     def unary(
         self,
-        method_name: str,
+        interface: Optional[Callable] = None,
+        method_name: Optional[str] = None,
+        params_types: Optional[List[Type]] = None,
+        return_type: Optional[Type] = None,
+        codec: Optional[str] = None,
         request_serializer: Optional[SerializingFunction] = None,
         response_deserializer: Optional[DeserializingFunction] = None,
     ) -> RpcCallable:
-        return self._callable(
-            MethodDescriptor(
-                method_name=method_name,
-                arg_serialization=(request_serializer, None),
-                return_serialization=(None, response_deserializer),
-                rpc_type=RpcTypes.UNARY.value,
+        """
+        Create unary RPC call.
+
+        Supports both automatic mode (via interface) and manual mode (via 
method_name + params_types + return_type + codec).
+        """
+
+        # Validate
+        if interface is None and method_name is None:
+            raise ValueError("Either 'interface' or 'method_name' must be 
provided")
+
+        # Determine the actual method name to call
+        actual_method_name = method_name or (interface.__name__ if interface 
else "unary")
+        
+        # Build method descriptor (automatic or manual)
+        if interface:
+            method_desc = DubboTransportService.create_method_descriptor(
+                func=interface,
+                method_name=actual_method_name,
+                parameter_types=params_types,
+                return_type=return_type,
+                interface=interface,
             )
+        else:
+            # Manual mode fallback: use dummy function for descriptor creation
+            def dummy(): pass
+
+            method_desc = DubboTransportService.create_method_descriptor(
+                func=dummy,
+                method_name=actual_method_name,
+                parameter_types=params_types or [],
+                return_type=return_type or Any,
+            )
+
+        # Determine serializers if not provided
+        if request_serializer and response_deserializer:
+            final_request_serializer = request_serializer
+            final_response_deserializer = response_deserializer
+        else:
+            # Use DubboTransportService to generate serialization functions
+            final_request_serializer, final_response_deserializer = 
DubboTransportService.create_serialization_functions(
+                transport_type=codec or "json",
+                parameter_types=[p.annotation for p in method_desc.parameters],
+                return_type=method_desc.return_parameter.annotation,
+            )
+
+        # Create the proper MethodDescriptor for the RPC call
+        # This should match the structure expected by your RpcCallableFactory
+        rpc_method_descriptor = MethodDescriptor(
+            method_name=actual_method_name,
+            arg_serialization=(final_request_serializer, None),  # 
(serializer, deserializer) for arguments
+            return_serialization=(None, final_response_deserializer),  # 
(serializer, deserializer) for return value
+            rpc_type=RpcTypes.UNARY.value,
         )
 
+        # Create and return the RpcCallable
+        return self._callable(rpc_method_descriptor)
+
     def client_stream(
         self,
-        method_name: str,
+        interface: Optional[Callable] = None,
+        method_name: Optional[str] = None,
+        params_types: Optional[List[Type]] = None,
+        return_type: Optional[Type] = None,
+        codec: Optional[str] = None,
         request_serializer: Optional[SerializingFunction] = None,
         response_deserializer: Optional[DeserializingFunction] = None,
     ) -> RpcCallable:
-        return self._callable(
-            MethodDescriptor(
-                method_name=method_name,
-                arg_serialization=(request_serializer, None),
-                return_serialization=(None, response_deserializer),
-                rpc_type=RpcTypes.CLIENT_STREAM.value,
+        """

Review Comment:
   Ok 
   Now i understand 
   Thx for clarification 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to