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

laputa-trigger-modules

v0.2.2

Published

Laputa项目,由某程序触发进行相关业务;项目没有入口,以module为主;前置程序触发调用,如node-red

Downloads

5

Readme

laputa-trigger-modules

version:0.2.x

description

Laputa项目,由某程序触发进行相关业务;项目没有入口,以module为主;前置程序触发调用,如node-red

使用

初始化,并执行

新增运行模式,两种模式 whole/specify 完整模式和指定模式;

  • whole 表示对全部租户库支持;该项为默认配置

  • specify 表示对指定租户库支持,需要额外传入租户库名配置

    options={runningMode:'specify',tenants:['laputa']}
//连接rethinkdb配置对象,不定义则使用默认配置文件中的配置
//运行模式 whole/specify
let options={runningMode:'specify',tenants:['laputa']};
//调用模块
const trigger = require('laputa-trigger-modules');
//获取r模块
//获取初始化模块,并初始化环境,初始化业务会将表 “system” 和 “deviceType” 数据缓存
async function begin() {
    const r = trigger.rethinkdb.init(options.db);
    options.r = r;
    const appInit = trigger.appInit(options);
    const caches = await appInit.init();
    const frame = { r: r, caches:caches};
    return frame;
}
begin();

自动生成工单业务

传入的数据主体为msgpack序列化格式 topic 格式中包含tenant库名;符合如“rcg/event/sh/laputa/env”,第4位为库名

生成的新工单数据会放入回调方法中被执行

/**
* ticket 新生成的工单数据对象
* topic 租户库名
**/
callback(ticket,topic){}

调用方法

/**
 * ......
 * ......
 * 省略启动时执行
 **/

//获取自动生成工单模块
const autoTicket = trigger.autoTicket;

//假设进入的数据
const message = {
    "deviceId": "5b2f68a5-1adb-4c8e-8fbf-811523779698",
    "monitorId": "436cf7b3-d6c0-4077-a1a7-25406ca11308",
    "state": "alarm",
    "value": 67.57,
    "_updateTime": 1503987070305
}

const _message=msgpack.encode(message);
const topic='rcg/event/sh/laputa/env';

begin().then(frame => {
    autoTicket(frame, topic, _message, function (ticket, topic) {
        console.log('new ticket', ticket, topic);
    });
});
    

推送数据Hook模块

  • 用于生成web hook,触发数据推送
    //调用模块
    const {PushMessageQueue} = require('laputa-trigger-modules').manual2Push;

    //初始化接收推送数据队列
    const queuePush = new PushMessageQueue();

    //数据传入
    queuePush.start_check(topic, pushData);

    //获取最新待推送数据
    let msg=queuePush.oneByOne();
    console.log(JSON.stringify(msg.app));

内部模块调用消息推送

    const {  InnerProcess } = require('laputa-trigger-modules').manual2Push;
    //必须要已经有创建好的‘queuePush’
    const innerPush = new InnerProcess(queuePush);
    //推送消息
    innerPush.okMessage(pushData);

License

公司内部使用