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

egg-consul-ddz

v1.1.5

Published

egg-consul-ddz 插件,功能包括: 1. 应用启动时,注册服务 1. 设置定时任务,循环获取consul注册的服务,并且检查健康信息,将配置的指定名称并且没有问题的服务信息保存在内存中 2. 从内存中获取指定名称的服务 3. 应用关闭时,注销consul上的服务

Downloads

3

Readme

简介

egg-consul-ddz 插件,功能包括:

  1. 应用启动时,注册服务
    1. 设置定时任务,循环获取consul注册的服务,并且检查健康信息,将配置的指定名称并且没有问题的服务信息保存在内存中
  2. 从内存中获取指定名称的服务
  3. 应用关闭时,注销consul上的服务

使用

安装

yarn add egg-consul-ddz

插件启用

// plugin.js
exports.eggEos = {
  enable: true,
  package: "egg-consul-ddz"
};

插件配置

需要在config.*.js 文件中配置以下参数:

 consulDdz: {
      findTime: '1m', // 发现服务的间隔时间
      server: {
        host: '10.199.6.35',
        port: 8500,
        secure: false,
      },
      serviceList: [ // 服务发现列表
        {
          referName: 'plutusCore', // 引用名,后续可用 app.services.referName 访问服务
          service: 'plutus-core', // 服务id
        },
        {
          referName: 'plutusGeneral',
          service: 'plutus-general',
        },
      ],
      register: false, // 是否注册自己的服务,如果不注册则无需配置 client 参数
      client: {
        name: 'egg-gateway-eos', // 服务每次
        id: 'egg-gateway-eos', // 服务Id,可以与名称一致
        tags: 'egg-gateway-eos', // 标签信息
        address: '127.0.0.1', // 服务地址
        port: 8500, // 服务端口号
        check: {
          http: '127.0.0.1:7000', // http服务地址
          interval: '5s', // 健康检测轮询时间
          timeout: '10s', // 超时时间
          status: 'critical', // 初始化服务状态
        },
      },
    },

服务注册成功,会将所有服务信息挂载在 application 实例化后的 app 对象 consulServices 属性上,可以通过如下方式获得

// 获得服务信息
app.consulServices[referName] 

更新记录

1.0.1

  1. 修改获取 consul 注册服务方法,为只获取状态为通过的服务
  2. 将 consul 相关方法转移到 application 中,在引用时无需再传入 app 对象
  3. 配置定时任务 schedule ,每隔 1m 分钟去 consul 获取,检查和更新健康服务信息

1.0.2

  1. 解决 format 方法引用错误bug

1.0.3

  1. 修改日志输出中对findService方法输出错误BUG
  2. 每次定时检查consul服务时候,增加获取成功的服务日志输出

1.0.4

  1. 修改获取成的服务日志输出代码,转移到定时器中

1.0.7

  1. 修改日志打印方式为 app.coreLogger

1.0.8

  1. 增加说明文档,和BUG提交地址

1.0.9

  1. 更新说明文档

1.1.0

  1. 更新在引用启动前,先运行发现服务定时器,获取完毕后再启动应用

1.1.1

  1. 删除1.1.0代码

1.1.2

  1. 获得最新结果后,判断与本地配置是否深度相等,相等则不更新

1.1.3

  1. 修改 application.js 中 consul 的方法,避免与其他插件有冲突

1.1.4

  1. 转移app.js中启动方法

1.1.5

  1. 修改consul初始化位置,避免出现例如配置了apollo,导致必要参数未加载的时候,就已经进行了初始化导致失败。