- Node.js v12 or higher
This package is available in the Node Package Repository and can be easily installed with npm or yarn.
$ npm i @slimio/alert
# or
$ yarn add @slimio/alertA simple addon that will throw an alarm every second...
importAddonfrom"@slimio/addon";importalertfrom"@slimio/alert";importmetricsfrom"@slimio/metrics";consttest=newAddon("test");const{ Entity }=metrics(test);const{ Alarm }=alert(test);constALARM_INTERVAL=1_000;constMY_ENTITY=newEntity("MyEntity",{description: "Hello world!"});test.registerInterval(()=>{newAlarm("hello world!",{correlateKey: "test_alarm",entity: MY_ENTITY});},ALARM_INTERVAL);exportdefaulttest;The alert package return a function described by the following interface:
declarefunctionAlert(addon: Addon): {Alarm: typeofAlarm;};Each instance of Alarm are unique to the local Addon.
This section describe the methods and properties of Alarm Object.
constructor(message: string, options: Alert.ConstructorOptions)
Create a new Alarm Object.
newAlarm("hello world alarm",{correlateKey: "test_alarm"});Available options are described the following interface:
interfaceConstructorOptions{severity?: SlimIO.AlarmSeverity;entity?: Metrics.Entity|string|number;correlateKey: string;}toJSON(): SlimIO.RawAlarm
Return a raw alarm. Refer to @slimio/tsd for more information.
declareclassAlarmextendsevents{publiccid: SlimIO.CID;publicseverity: number;publicentity: Metrics.Entity|number;publicmessage: string;publiccorrelateKey: string;staticDefaultSeverity: number;staticSeverity: SlimIO.AlarmSeverity;}Severity is defined in @slimio/tsd as follow:
enumAlarmSeverity{Critical,Major,Minor}The default severity is defined as 1 for Major.
| Name | Refactoring | Security Risk | Usage |
|---|---|---|---|
| @slimio/is | Minor | Low | Type checker |
| @slimio/safe-emitter | Medium | Safe emitter | |
| @slimio/timemap | Low | Time map | |
| @slimio/utils | Minor | High | Bunch of useful functions |
MIT