npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@taccisum/egg-apollo

v1.0.2

Published

egg apollo client plugin base on ctrip-apollo

Downloads

5

Readme

egg-apollo

NPM version npm download

egg-apollo插件基于ctrip-apollo v4.4.0,帮助你在eggjs下快速与apollo配置中心进行集成。

安装

通过npm仓库安装

$ npm i @taccisum/egg-apollo --save

使用

// {app_root}/config/plugin.js
exports.apollo = {
  enable: true,
  package: '@taccisum/egg-apollo',
};

配置

// {app_root}/config/config.default.js
exports.apollo = {
  enabled: true,
  timeout: 3000, // 等待超时时间
  namespaces: [ 'application' ]

  // 其它配置沿用自ctrip-apollo,更多请参考 https://github.com/kaelzhang/ctrip-apollo
  appId: 'foo-service', // your application id in apollo
  host: 'http://localhost:8070',  // apollo config service地址
};

使用示例

egg-apollo在启动后会自动从apollo拉取配置并合并到eggjs本地配置中,一般不需要做额外的操作。点击这里查看合并规则

如果确实有需要,你也可以通过以下方式获取到apollo的客户端

const client = app.apollo;
// do something with apollo client

使用参考

配置合并规则

每个应用只能指定唯一的appIdcluster,但可以指定多个namespace,多个namespace的配置会按照一定规则合并后再与本地配置合并。

具体规则如下:

namespaces通过config.apollo.namespaces | array配置,多个namesapce优先级从右到左降低,例如指定了3个namespace

exports.apollo = {
  namespaces: [ 'application', 'tac.foo1', 'tac.foo2' ]
}

其中

application

a=a
b=b
c.d=cd

tac.foo1

a=a1
b=b1

tac.foo2

b=b2

则配置会按照tac.foo2 -> tac.foo1 -> application的顺序合并,合并后的结果将是

a=a1
b=b2
c.d=cd

最终被解析为以下json对象与本地config合并

{
  "a": "a1",
  "b": "b2",
  "c": {
    "d": "cd"
  }
}

问题和建议

empty now.

License

MIT