nope/wiki/12-Dispatcher.ipynb
2022-01-18 21:51:19 +01:00

85 lines
3.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# NoPE - Dispatcher\n",
"\n",
"The NoPE-Dispatcher is designed as Layer between the different Modules / Dispatchers. They allow distributed computing or just a simple ***Service oriented Architecture*** (*SOA*). A dispatcher is used to link the modules, share data and events and provide a remote procedure call (rpc) interface.\n",
"\n",
"## Building Blocks of a Dispatcher:\n",
"\n",
"| element | description | \n",
"|-|-|\n",
"| `connectivityManager` | establishes a connection to other dispatchers and manages the status of the remotely connected dispatchers. It checks their health and removes dead dispatchers. |\n",
"| `eventDistributor` | shares events accross the network (or internally). You can use this element to listen for specific events. The subscription to those events allows `mqtt`-patterns. Additionaly, you are allowed to emit event on specific topics, or pattern based topics |\n",
"| `dataDistributor` | shares data accross the network (or internally). In comperisson to events, data is persistent and is available all the time. You can use this sub-module to listen for specific data-changes (install data-hooks), pull specific data or push data. You can pull / push data using a `mqtt`-pattern based path. |\n",
"| `rpcManager` | Used to perform `remote procedure calls` (see [here](https://de.wikipedia.org/wiki/Remote_Procedure_Call)). The manager keeps track of the available services. You must use the sub-module to register/unregister (new) services. |\n",
"| `instanceManager` | Used to create/dispose (remote) instances. The manager keeps track of the available instances in the network, allows to create `wrappers` for those instances. You must use the sub-module to register/unregister (new) instances. To allow the system to provide a service for creating instances of as specific type, you can provide a generator and provide it as `service`. |\n",
"\n",
"## Create a Dispatcher\n",
"\n",
"To start exploring the capabilities of the dispatcher we will firstly create a dispatcher with the code below:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"// First lets install nope using npm\n",
"const nope = require(\"../dist-nodejs/index.nodejs\")\n",
"\n",
"// Lets create our dispatcher\n",
"const dispatcher = nope.dispatcher.getDispatcher({\n",
" // We will use the event layer (which just runs internally)\n",
" communicator: nope.getLayer(\"event\"),\n",
"\n",
" // We will adapt the timings (normally, we send a hartbeat and check for dead dispatchers)\n",
" timings: {\n",
"\n",
" /**\n",
" * Interval for the alive message given in [ms]. If \"0\" is provided,\n",
" * no alive messages are provided\n",
" *\n",
" * @author M.Karkowski\n",
" * @type {number}\n",
" */\n",
" sendAliveInterval: 0,\n",
"\n",
" /**\n",
" * Interval, to check the other dispatcher for being slow, dead, etc..\n",
" * should be lager then the \"sendAliveInterval\". The value is given in [ms]\n",
" * If \"0\" is provided, no alive messages are provided\n",
" *\n",
" * @author M.Karkowski\n",
" * @type {number}\n",
" */\n",
" checkInterval: 0\n",
" \n",
" }\n",
"});\n",
"console.log(dispatcher)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "JavaScript (Node.js)",
"language": "javascript",
"name": "javascript"
},
"language_info": {
"file_extension": ".js",
"mimetype": "application/javascript",
"name": "javascript",
"version": "17.3.1"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}