Git Product home page Git Product logo

Comments (3)

hufeng avatar hufeng commented on May 20, 2024

Maybe process.nextTick is good idea.

from dubbo-js.

hufeng avatar hufeng commented on May 20, 2024

不太容易去掉,和设计相关
希望在node和zookeeper连接的时候就确定订阅的接口信息
获取负载信息初始化socket pool不希望把这个过程推迟到请求处理的过程中

但是可以封装一些方法来简化这个问题,

registry: 'localhost:2181'
application:
  name: node-dubbo-consumer
interfaces:
  demoService:
     interface: 'com.alibaba.dubbo.demo.DemoService'
     version: '2.0.0'
     group: ''
     from: '../providers'              

from dubbo-js.

hufeng avatar hufeng commented on May 20, 2024

总算找到了解决这个问题的方案,这个问题的难点不是怎么实现,而是typescript怎么去定义暴露服务类型,给出代码的完美提示。这个还真有点难。但是不去解决这个问题,真的代码写的很炸。

import A from 'A',
import B from 'B'
import c from 'C'
import ... 

const dubbo = new Dubbo({
  interfaces: [
   'A',
   'B',
   'C',
  ......
  ]
});

const a = A(dubbo);
const b = B(dubbo);
const c = C(dubbo);
......

//整合egg
app.dubbo = {
 a,
 b,
c,
......
}

同学们想这个接口规模再提高10x 代码就无法看了,当然代码上有优化的空间,但是痛点就是类型的代码提示,一旦动态就无法精确获得类型提示。

我们的翻译器生成的代码格式基本都是
export xxProvider = (dubbo: Dubbo): XxProvider => dubbo.proxyService({...});

在typescript2.8以后支持了conditional type.可以很好解决我们这个问题。

image

将provider集合起来,然后放入Dubbo中,
image

就可以获取优秀的开发体验

image

enjoy :)

from dubbo-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.