Coder Social home page Coder Social logo

lvgithub / ctrip-apollo-client Goto Github PK

View Code? Open in Web Editor NEW
74.0 2.0 21.0 2.19 MB

This is a client library for Apollo(A reliable configuration management system) written in Node.js.

License: Other

JavaScript 94.52% TypeScript 5.01% Shell 0.46%
apollo-client ctrip-apollo configuration-management

ctrip-apollo-client's Introduction

🌈🌈🌈 这是用Node.js编写的Apollo(配置中心)客户端

扫码进交流群

image

Introduction

Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性,适用于微服务配置管理场景。

本项目为Node.js 客户端,工作原理如下:

图裂了,看 assets/README/img.png 配置中心配置以点分隔如 mysql.host:127.0.0.1 ,客户端会自动转化为Json

{ mysql:{ host: 127.0.0.1 } } }

apollo 服务端测试环境:

Examples 使用下面的环境作为测试服务,可直接运行。

Features

  • 配置热更新
  • 缓存配置到本地
  • 灰度发布
  • 支持 TypeScript

Install

npm i @lvgithub/ctrip-apollo-client

Links

Examples

Benchmark

注入方式 性能 用例数
不热更新 736,896,802 ops/sec 82 runs sampled
热更新 hotValue() 2,021,310 ops/sec 87 runs sampled
热更新 @value 2,161,312 ops/sec 87 runs sampled
原生访问 704,644,395 ops/sec 82 runs sampled

MIT

ctrip-apollo-client's People

Contributors

ddzyan avatar dependabot[bot] avatar lvgithub avatar qb2014 avatar shenlanchenwei avatar tiejunhu avatar unliar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ctrip-apollo-client's Issues

可以实现同步获取配置吗?

之前项目里的配置都存放在config.js文件里,其他地方使用都是直接import的,如果可以实现同步获取apollo配置的话,可以完美替换这种场景。

Bug

async polling () {
let pollingCount = 1
while (true) {
this.info('polling count:', pollingCount++)
try {
await this.pollingNotification()
await sleep(2000) // 这里不加会阻塞事件循环 长链接进不来 this.pollingNotification()加的已经被catch掉了
} catch (error) {
this.error('polling error:', error)
await sleep(1000)
}
}
}

304 报了个error

apollo-client: pollingNotification error: Request failed with status code 304
304应该是使用缓存,但是却报了个error

Angular 10使用异常

我想在Angular 10 中使用这个客户端读取apollo 配置中心的配置信息。
在npm run build 时 出现以下异常:

ERROR in ./node_modules/@lvgithub/ctrip-apollo-client/src/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/robin/Regtics/regtics-web/node_modules/@lvgithub/ctrip-apollo-client/src'

ERROR in ./node_modules/@lvgithub/ctrip-apollo-client/src/index.js
Module not found: Error: Can't resolve 'path' in '/Users/robin/Regtics/regtics-web/node_modules/@lvgithub/ctrip-apollo-client/src'

hotValue() 里面给 configurations 里确实存在的 key 但是.value 取不到值

config :>>  {
  application: {
    appId: 'xxx',
    cluster: 'default',
    namespaceName: 'application',
    configurations: {
      NODE_ENV: 'development',
      HCAPTCHA_BASE_URL: 'https://hcaptcha.com',
    },
    releaseKey: 'xxx'
  }
}
configApollo :>>  {
  NODE_ENV: 'development',
  HCAPTCHA_BASE_URL: 'https://hcaptcha.com',
}

这个是配置,我取 hotValue('HCAPTCHA_BASE_URL:123') namespace 默认 application,然后取不到这个值,返回的是123说明走了 defaultValue 逻辑

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.