User Tools

Site Tools


sib:callers:generalcaller

GeneralCaller

Overview

The GeneralCaller SIB Caller implements any “non-standard” dataflow, that is a dataflow where there is no specific standard SIB Caller implemented.

Workflow

  • Subscribe: .custom/topic
    • on message:
      • custom.inputFormat
      • custom.getData
      • custom.outputFormat
      • apply/copy SIBHeader
      • Publish: msg._sibheader.responseTopic

Custom configuration

generalcaller/custom.js
var generalCallerCustom = {
	_id: "gcs:1",
	_name: "Sample of general caller",
	getData: (topic, msg, callback)=>{
		// Got a message msg on topic
		// Generate some data and return to the callback
 
		return callback( {success:true, message:"Caller method run", _sibheader: msg._sibheader} );		
	},
	inputFormat: (topic, msg, callback)=>{
		// Format the input data
		callback( msg );
	},
	outputFormat: (topic, msg, callback)=>{
		// Format the output data
		callback( msg );
	},	
 
	mqtt: "mqtt://192.168.126.129",			// MQTT Server to listen to
	topic: "SIB/SAMPLES/GENERALCALLER",	// MQTT Topic to subscribe to
	loggerCfg: {
		dest: {
			file: false,
			console: true,
			mqtt: true
		}
	},
};
 
module.exports = generalCallerCustom;
  • _id: The unique ID of this service
  • _name: A plaintext description of this service
  • getData(topic, msg, callback): The data collection method. The topic and message triggering the workflow is passed as arguments and on completion the callback method must be run with the response data in JSON format as the only argument.
  • inputFormat(topic, msg, callback): The method that is run on service activation. The original message is passed as the argument and the input to the callback method must be a JSON formatted message conforming to the SIB message standard.
  • outputFormat(topic, msg, callback): This message is run on the response data before publishing to the response topic. The response message is passed as the argument and the input to the callback method must be a JSON formatted message conforming to the SIB message standard.
  • mqtt: The MQTT connection string for the internal MQTT transport
  • topic: The MQTT topic to subscribe to on the internal MQTT transport
  • loggerCfg: A JSON Object defining what logger actions should be active for this service (see Logger Configuration
sib/callers/generalcaller.txt · Last modified: 2018/12/07 12:48 by hubbe