apache / dubbo-js

The Typescript implementation of Apache Dubbo. An RPC and microservice framework for Node.js and Web development.
https://dubbo.apache.org/
Apache License 2.0
766 stars 160 forks source link

支持脱离 IDL 的开发模式 #345

Open chickenlj opened 1 year ago

chickenlj commented 1 year ago

image

除了以上api之外,我们可以考虑引入新的api,让用户把service、method、arguments(json)直接输入进来,发起调用,比如,举个例子:

对于IDL生成的ExampleService

export const ExampleService = {
  typeName: "apache.dubbo.demo.example.v1.ExampleService",
  methods: {
    /**
     * @generated from rpc apache.dubbo.demo.example.v1.ExampleService.Say
     */
    say: {
      name: "Say",
      I: SayRequest,
      O: SayResponse,
      kind: MethodKind.Unary,
    },
  }
} as const;

我们可以引入 API const client = createGenericPromiseClient(transport); client.call("apache.dubbo.demo.example.v1.ExampleService", "say", {sentence:hello})