New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

kermit-service-observer

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kermit-service-observer

Inter service event listener for kermit.

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
4
-50%
Maintainers
1
Weekly downloads
 
Created
Source

Kermit Module

kermit-service-observer - 0.1.1

Inter service event listener for kermit.

Install

$ npm install --save kermit-service-observer

Include

Register the observer service in your application services config (eg. config/application.config.js).

module.exports = {
  ...
  app: {
    services: {
      observer: 'kermit-service-observer/ObserverService'
      ...
    }
  }
  ...
}

Use

A common use case is to execute an panic method in case of any application service triggers an error, for example in case of a lost db connection etc.

To archive this register the listener in your application's pre launch phase:

  // src/Application.js
  ...
  
  launch() {
    super.launch();
    
    let observer = this.getServiceManager().get('observer');
    
    // execute the callback in case of any service (referenced by its service-key)
    // triggers an "error" event.
    observer.awaitAny([
      'mongo-service', 'redis-service', 'rabbit-service'
    ], 'error', (err, observation) => {
        if (err) {
          // an error within the service observation occured.
          throw err;
        }
        
        // this is where your recovery code goes.
        
        console.error(
          'the service', observation.service,
          `triggered an ${observation.event} event, passing the following arguments:`,
          observation.args
        );
    });
    
    return this;
  }
  ...
  

The service observer is also handy to use for assure the readyness of your asynchronous application services:

  // src/Application.js
  ...
  
  launch() {
    super.launch();
    
    let observer = this.getServiceManager().get('observer');
    
    // execute the callback in case of all services (referenced by its service-keys)
    // have triggered an "ready" event.
    observer.awaitAll([
      'mongo-service', 'redis-service', 'rabbit-service'
    ], 'ready', (err, observations) => {
      if (err) {
        // an error within the service observation occured.
        throw err;
      }
      
      // this is where your on-all-services-ready-to-use code goes.
      console.info('All services are ready!');
    });
    
    return this;
  }
  ...

LICENSE

The files in this archive are released under BSD-2-Clause license. You can find a copy of this license in LICENSE.

Keywords

kermit

FAQs

Package last updated on 07 Jul 2016

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