The readme is divided into two major parts. Part 1 explains the demo setup and runs it. Part 2 talks about usage of the DDA resource in EDGELESS workflows to create other functions.
The purpose of this demo is to showcase the capabilities of the DDA sidecar in conjunction with functions that utilize the Data Distribution Agent as a component of Edgeless. This demo highlights how serverless functions and workflows can communicate through a decentralized, data-centric mesh, both internally and with external systems. The diagram below illustrates the architecture of this mesh.
This concept is realized based on an Open Source Component also called DDA available here.
To successfully run and interact with the demo, the edgeless environment needs to be configured and built. If you have this already up and running, you can skip the next section.
Make sure you have build all artifacts and binaries from the EDGELESS core. For details on doing this for the different platforms, check the documentation here - building guide.
After completing this you should have the following executables in the directory target/debug/
from the repository root:
Executable name |
---|
edgeless_con_d |
edgeless_orc_d |
edgeless_node_d |
edgeless_cli |
All components available need there respective configuration files. For convenience you find in examples/dda_demo/scripts
a script ./010_create_edgeless_configs.sh
to generate the config files for the DDA Demo(s).
We assume that the prerequisites are already available. To setup the demo, you need to move to folder examples/dda_demo/scripts
and follow the steps.
DDA needs a MQTT broker to publish and subscribe to actions and events. So we need to setup a MQTT broker and configure access to the broker in all dependent functions.
- Setup and run a MQTT Broker, for ex
Mosquitto
- Configure MQTT Broker for all DDAs in the demo setup by adding the MQTT address in the following configs:
- DDA sidecar configuration for the DDA EDGELESS resource:
dda.yaml
in the parent folderexamples/dda_demo/dda.yaml
. - Non-EDGELESS components and services like for instance the two mock services in
examples/dda_demo/mock-services/mock-robot-arm
andexamples/dda_demo/mock-services/mock-temperature-sensor
.
- DDA sidecar configuration for the DDA EDGELESS resource:
- DDA has a dependency on
go
. So make sure thatgo
is installed and path is accessible in environment. - Run the EDGELESS DDA sidecar by running
020_run_dda.sh
. - In case you get the following error
./020_run_dda.sh: line 10: dda: command not found
, this is becausedda
is installed but it is not accessible in the current environment path. To solve this, runexport PATH=$PATH:$(go env GOPATH)/bin
. - If you still get the same error, the
dda
resource has been installed elsewhere. Add that location to thePATH
variable in environment.
Next, we start the edgeless controller, orchestrator, and node components.
- In the
scripts
folder, run./030_run_edgeless_ctrl.sh
to start the controller. - Run
./031_run_edgeless_orc.sh
to start the orchestrator. - Run
./032_run_edgeless_node.sh
to start one edgeless node.
You are now ready to deploy workflows and functions via the EDGELESS cli.
- The Demo consists of:
- two mock services - a. a mock temperature service, which continuously issues temperature data via its DDA using the event pattern, and b. a mock robot arm, which can be moved based on action commands received via its DDA.
- an EDGELESS workflow, consisting of a DDA resources and two functions a. a check temperature function which checks if a temperature is in a certain range, and b. a function which generates a movement command based on the data received from the check temperature function.
- The DDA subscribes to temperature events according its configuration in the workflow.
- As soon as a temperature event is received by the DDA, it issues a cast event to the check temperature function according its internal mapping of topics to casts on the dataplane.
- The check temperature function process the data of the event, and depending on the result a cast to the move arm function is issued on the dataplane with a corresponding parameter.
- The move arm function processes the event and the data, and calculates a command for the robot arm. The command is issued as Action pattern via the DDA resource.
- The mock robot arm receives the event via the DDA, moves the arm according the command up or down and acknowledges the Action pattern via the DDA back to the move arm function.
After setting up the EDGELESS and DDA environment according the two previous sections we start next the none EDGELESS mock services.
The two mock services use each use a DDA by means of an integrated DDA library to publish and subscribe to the MQTT broker. The mock_temperature_sensor
publish certain random temperature in a pre-defined time interval. The second mock service mock_robot_arm
imitates movement of a robot arm depending on the commands received from the demo workflow.
- Run
mock_robot_arm
with the script./040_run_mock_actor.sh
. This service mocks movement of a robot arm. It prints robot arm motion in console in response to action sent from edgeless resource. - Run
mock_temperature_sensor
with the script./050_run_mock_sensor.sh
. This service mocks a sensor which sends out random temperature readings in a fixed time interval. The functioncheck_temperature
(introduced in the next section) checks the temperature and invokes an action when needed.
In the dda_demo/functions
folder you can find two previously described EDGELESS functions necessary for the workflow:
check_temperature
- Check temperature functions waits for temperature events from DDA resource. When it receives a temperature, it checks it against a predefined range. If the temperature is higher than the threshold of 60 or lower than 40, it invokes themove_arm
function, and sends the difference to the range as additional parameter.move_arm
- The move arm function is triggered as an action in response to the temperature anomaly identified incheck_temperature
function. The function calculates a control parameter (10% of the temperature difference) and uses this to invoke themock_robot_arm
external mock services via the DDA as action command.
The functions can be build by calling ./060_build_demo_functions.sh
both for the check temperature function and the move_arm function.
Now that we have all the dependencies up and running, let's run the demo.
- Deploy and run workflow with
UUID=$(../../../target/debug/edgeless_cli workflow start ../workflow.json)
or call./070_run_demo_robotarmmock.sh
in thescripts
folder.
You should see in
edgeless node
console (the one where./032_run_edgeless_node.sh
is running)mock_temperature_sensor
console (the one where./050_run_mock_sensor.sh
is running)mock_robot_arm
console (the one where./040_run_mock_actor.sh
is running)
The configuration of a dda resource
in edgeless is done in the correspondingworkflow.json
. Inside the workflow.json
, configuration for dda topics to be subscribed and dda publications to be performed are passed in form of a JSON string.
This can be done by modifying the two following fields that need to be updated to be used in other settings.
dda_com_subscription_mapping
: The subscription array is an array of json objects that define which topics to subscribe to and what to do when an event is encountered. It contains following fieldsddatopic
: This is the topic name to which DDA should subscribe to.ddapattern
: It defines the ddapattern should be used. Currently only theevent
one-way pattern is supported. In future all other DDA patterns will be supported.cast_mapping
: Defines which identifier will be used to forward the event via the dataplane to a specific function.
dda_com_publication_mapping
: The publication array is an array of json objects which define which calls should the dda resource handle, and how would it behave in that case. It contains following fieldspubid
: Defined which dataplane messages should the dda resource be listening for.ddatopic
: Defines which ddatopic the cast/call should be mapped to. In the current implementation, it only performspublish action
pattern. In future, it will be extended to other patterns as well.
Please be advised that currently the local store features, and the state synchronization via RAFT as further core features of the DDA are not yet implemented. These features will be made available in future.
Code and documentation copyright 2024 Siemens AG.
Code is licensed under the MIT License.