Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

harcon

Package Overview
Dependencies
Maintainers
1
Versions
326
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

harcon - npm Package Compare versions

Comparing version 0.9.32 to 0.9.34

8

lib/Inflicter.js

@@ -8,3 +8,3 @@ var Communication = require('../lib/Communication');

var VERSION = exports.VERSION = '0.9.32';
var VERSION = exports.VERSION = '0.9.34';

@@ -166,2 +166,3 @@ function extend(obj, extension){

* @method addict
* @param {String} division, mandatory
* @param {String} name Name of the listener - needed for logging

@@ -171,3 +172,3 @@ * @param {String} eventName Eventname subscription

*/
inflicter.addict = function( name, eventName, fn, division ){
inflicter.addict = function( division, name, eventName, fn ){
var flamestarter = new Flamestarter( this.barrel, division, name, eventName, fn, this.logger );

@@ -184,3 +185,4 @@ flamestarter.sliceArguments = this.sliceArguments;

* @method ignite
* @param {String} source Name of the listener - needed for logging, mandatory
* @param {String} external ID, mandatory, can be null
* @param {String} division, mandatory
* @param {String} event Name of the even to emit, mandatory

@@ -187,0 +189,0 @@ * @param {String} params A vararg element possessing the objects to be sent with the message. Can be empty

{
"name": "harcon",
"version": "0.9.32",
"version": "0.9.34",
"description": "Messaging/Service Bus for the harmonic convergence of node-based enterprise entities.",

@@ -49,3 +49,3 @@ "keywords": [

},
"_id": "harcon@0.9.32"
"_id": "harcon@0.9.34"
}

@@ -25,3 +25,3 @@ Harcon - Messaging/Service Bus for the harmonic convergence of node-based enterprise entities or in-browser communication between web components

- __Advanced routing & listening__: qualified names, regular expressions, wildcards can be all used
- __Advanced routing & listening__: system fragmentation, qualified names, regular expressions, wildcards, etc.

@@ -46,3 +46,3 @@ __!Note__: Harcon's concept is to introduce a clean and high abstraction layer over messaging between entities. Like in case of every abstraction tool, for webapps which are simple as 1, it can be proven as a liability.

// define a listener function listening every message withing the context "greet"
inflicter.addict('peter', 'greet.*', function(greetings1, greetings2, callback){
inflicter.addict( null, 'peter', 'greet.*', function(greetings1, greetings2, callback){
callback(null, 'Hi there!');

@@ -63,3 +63,3 @@ } );

// will receive back 2 answers: 'Hi there!' and 'Bonjour!'
inflicter.ignite( 'greet.everyone', 'Whatsup?', 'How do you do?', function(err, res){
inflicter.ignite( null, null, 'greet.everyone', 'Whatsup?', 'How do you do?', function(err, res){
console.log( err, res );

@@ -94,11 +94,11 @@ } );

// Qualified name - will answer to only this message
inflicter.addict('hugh', 'allocate.ip', function(callback){
inflicter.addict( null, 'hugh', 'allocate.ip', function(callback){
callback(null, 'Done.');
} );
// Wildcards - will answer anything within the context greet
inflicter.addict('peter', 'greet.*', function(callback){
inflicter.addict( null, 'peter', 'greet.*', function(callback){
callback(null, 'Done.');
} );
// Regular expression - will answer anything where message name start with string 'job'
inflicter.addict('john', /job.*/, function(callback){
inflicter.addict( null, 'john', /job.*/, function(callback){
callback(null, 'Done.');

@@ -157,3 +157,3 @@ } );

// Qualified name - will answer to only this message
inflicter.addict('karl', 'reserve.address', function( address ){
inflicter.addict( null, 'karl', 'reserve.address', function( address ){
// Do something...

@@ -203,2 +203,73 @@ } );

## Message exchange
When you defined your components, the need to send and receive messages arises. In a workflow, your component might initiate a message, response one or while responding one sends other ones.
The function-based components can perform only the latter 2 cases, cannot initiate anything by its own. This type of components are present to define services, listeners, definitely not serious business entities.
As you saw above, the serices functions might possess a parameter before the __callback__: _ignite_
```javascript
var order = {
name: 'Order',
context: 'order',
newVPN: function( customer, ignite, callback ){
ignite( 'allocate.address', '127.0.0.1', function(err, res){
callback(err, res);
} );
}
};
...
That ignite can be used to chain messages, which means to send messages during the processing of a received one. The tool to initiate sub-workflows.
Of course components are not just reacting entities, they might launch new workflows as well. Object-based components possesses an injected function: _ignite_ and can be used as follows:
```javascript
var timer = {
name: 'Timer',
scheduling: function( ){
this.ignite( 'validate.accounts', function(err, res){
} );
}
};
...
That ignite function is injected by the [harcon](https://github.com/imrefazekas/harcon) when you publish the components.
## Divisions
Systems can be orchastrated into divisions which is a tree structure actually. One can create divisions following the control-flow or responsibility-chain of the application.
Every component you deploy will belong to a division. If not declared, then to the system division where all system-level components are put.
Divisions is not just a logical grouping of components, but also an encapsulation-model. A component cannot send messages outside the own division but can send to the inner ones. This means, that system components can send to any component, but non-system components cannot reach the level of the main system or other branches of the division-tree.
Divisions give you a very easy-to-use structure to orchestrate your system. Of course, you can use the [harcon](https://github.com/imrefazekas/harcon) without using divisions, the complexity of your system will show if you needed it or not.
Let's define components and add them to divisions:
```javascript
// This will add John to the division 'workers'
inflicter.addict( 'workers', 'john', /job.*/, function(callback){
callback(null, 'Done.');
} );
// This will add Claire to the division 'entrance'
var claire = {
name: 'claire',
division: 'entrance',
context: 'greet',
simple: function (greetings1, greetings2, callback) {
callback(null, 'Enchanté, mon plaisir!');
}
};
```
Components in a division can be called to:
```javascript
inflicter.ignite( null, 'entrance', 'greet.simple', 'Hi', 'Ca vas?', function(err, res){
} );
```
Note: please keep in mind, that __inflicter.ignite__ can be and should be used only when you initiate a workflow from outside the harcon!
## Extension

@@ -205,0 +276,0 @@

@@ -26,3 +26,3 @@ var chai = require("chai");

// Publishes an event listener function: Peter. It just sends a simple greetings in return
inflicter.addict('peter', 'greet.*', function(greetings1, greetings2, callback){
inflicter.addict( null, 'peter', 'greet.*', function(greetings1, greetings2, callback){
callback(null, 'Hi there!');

@@ -32,3 +32,3 @@ } );

// Publishes another function listening all messages which name starts with 'greet'. It just sends a simple greetings in return
inflicter.addict('walter', 'greet.*', function(greetings1, greetings2, callback){
inflicter.addict( null, 'walter', 'greet.*', function(greetings1, greetings2, callback){
callback(null, 'My pleasure!');

@@ -35,0 +35,0 @@ } );

@@ -5,7 +5,7 @@ var Inflicter = require('../../../lib/Inflicter');

inflicter.addict('peter', 'greet.*', function(greetings1, greetings2, callback){
inflicter.addict( null, 'peter', 'greet.*', function(greetings1, greetings2, callback){
callback(null, 'Hi there!');
} );
inflicter.addict('walter', 'greet.*', function(greetings1, greetings2, callback){
inflicter.addict( null, 'walter', 'greet.*', function(greetings1, greetings2, callback){
callback(null, 'My pleasure!');

@@ -15,5 +15,5 @@ } );

setTimeout( function(){
inflicter.ignite( 'greet.simple', 'whatsup?', 'how do you do?', function(err, res){
inflicter.ignite( null, null, 'greet.simple', 'whatsup?', 'how do you do?', function(err, res){
console.log( err, res );
} );
}, 3000 );

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc