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

@lct/egg-tl5

v1.0.4

Published

egg plugin l5

Downloads

2

Readme

egg-tl5

egg l5插件, 依赖@tencent/cl5

Install

$ npm i @tencent/egg-tl5 --save

Usage

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

Configuration

如果用config来配置,则可以直用名称来取值

// {app_root}/config/config.default.js
exports.tl5 = {
  timeout: 0.2, // 可选,单位(s)
  test: {
    modid: 123456,
    cmd: 123456,
    timeout: 0.2  // 超时配置,可选 单位(s)
  },
  prod: {
    modid: 123,
    cmd: 123
  }
};

see config/config.default.js for more detail.

Example

// 直接用modid cmd 调用

  //@returns {ret:0, ip:'', port: 0}
  const res = await this.ctx.helper.getL5(123456, 123456); // modid, cmd.   第三个参数timeout可选 默认=0.2

按配置项调用

const res = await this.ctx.helper.getL5('test');// test / prod

重置上下文缓存

当次请求会把同一个modid:cmd 缓存到this.ctx.l5_cache下。保证同一次http请求只获取一次l5。 这里并不会一直缓存,context又会继续去拉取的。 如果需要刷新它,用参数-1

const res = await this.ctx.helper.getL5('test');
// 此处发现 res中的ip访问出错,想换个服务器重试一次
const res2 = await this.ctx.helper.getL5('test', -1);// 刷新this.ctx中的当前test l5缓存

//const res = await this.ctx.helper.getL5(123456, 123456, -1); // 刷新mod cmd 的当前this.ctx中的缓存

上报

this.ctx.helper.reportL5('test', {
  ret: 0,
  ip: '127.0.0.1',
  port: 8010,
  delay: 100,
  pre: 0,
  flow: 0
});

this.ctx.helper.reportL5('test', {
  ret: 0,
  modid: 1234,
  cmd: 1234,
  ip: '127.0.0.1',
  port: 8010,
  delay: 100,
  pre: 0,
  flow: 0
});

Questions & Suggestions

Please open an issue here.

License

MIT