Skip to content

Repository files navigation

Alert

versionMaintenanceMITdepsizeKnown VulnerabilitiesBuild Status

Requirements

Getting Started

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/alert

Usage example

A 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;

API

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.

Alarm

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.

Properties

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.

Dependencies

NameRefactoringSecurity RiskUsage
@slimio/isMinorLowType checker
@slimio/safe-emitter⚠️MajorMediumSafe emitter
@slimio/timemap⚠️MajorLowTime map
@slimio/utilsMinorHighBunch of useful functions

License

MIT

About

SlimIO Addon Alarms utilities

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages