Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@domain.js/cia

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@domain.js/cia

domain.js center 消息任务通用模块

latest
Source
npmnpm
Version
0.2.3
Version published
Maintainers
1
Created
Source

@domain.js/cia

Build status codecov

Installation

npm i @domain.js/cia --save

cnf

专属配置名称 cia

名称类型必填默认值描述样例
concurrencyintNo10task exec concurrency10
storeKeystringNocia-storeredis storage hash keycia-store

deps

模块名别名用到的方法描述
_NoneisFunction, maplodash
asyncNoneeachSeries, queuenpm i async
loggerNoneinfo, errordomain.js/logger
utilsUtryCatchLogutils functions
redisNonehset, hdel, hgetalldomain.js/redis

Usage

regist

注册消息到系统,提前注册的好处是可以预知有那些消息,都需要什么样的订阅者

  • eventName string 必填 消息名称
  • validator function 可选 消息数据验证函数
  • types [Object]
    • type string 必填 订阅者类型名称
    • timeout integer 可选 订阅函数执行的超时限定, 单位毫秒,超时也不会中断,只是会触发一次超时函数的执行
    • validator function 可选,订阅函数返回值验证函数,校验失败直接抛出异常
cia.regist('eventName', submitValidatorFunction, [
  {
    type: 'cleanCache', // 必填 订阅的名称
    timeout: 1000, // 可选 
  }
]);

连接cia系统,通过waiter来接收对应的消息

  • eventName string 必填 消息名称
  • type string 必填 接待者类型,要和 regist types里的type匹配
  • waiter function 必填 订阅函数
cia.link('eventName', 'cleanCache', waiter);

submit

提交函数,当有消息产生的时候通过改函数提交上去

  • eventName string 必填 消息名称
  • data any 必填 消息体数据

setFn

设置超时函数和执行订阅错误接收函数, 不设置的时候默认是 logger.info 和 logger.error

  • type string 必填 函数类型,timeouterror
  • function function 必填 设置的函数

checkReady

检测系统是否已准备好,返回 turefalse

isExiting

获取系统是否正在退出中,返回 truefalse

isExited

获取系统是否已退出,返回 truefalse

获取未被 link 的消息任务, 排查问题的时候需要用到

Keywords

message

FAQs

Package last updated on 03 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts