Sample Subscriber Apps
Subscriber apps consists of the following:
C++ Subscriber
The C++ subscriber and client are supported in Ubuntu operating systems or docker images. The C++ subscriber runs in the independent containers as ia_ubuntu_cpp_sample_sub
.
Go Subscriber
The Go subscriber and client are supported in Ubuntu operating systems or docker images. The Go subscriber runs in the independent containers as ia_ubuntu_go_sample_sub
.
Python Subscriber
The Python subscriber and client are supported are supported only in Ubuntu operating systems or docker images. The Python subscriber runs in the independent container ia_ubuntu_python_sample_sub
.
Note
The subscriber container comprises of both the subscriber and the client functionality.
High-level Logical Flow for Sample Subscriber Apps
The high-level logical flow of a sample subscriber app is as follows:
Sample apps use the ConfigMgr(
[WORK_DIR]/IEdgeInsights/common/libs/ConfigMgr/src/cfgmgr.c
) APIs to construct themsgbus
config from the ETCD. It fetches its private and public key and the publisher’s public key. It then creates the subscriber object (which subscribes to the same topic : publish_test) and starts receiving the data and prints the same onto a console.Client contacts the ETCD service and fetches its private key and the server’s public key. Then it creates a client object and sends a request to the server and receives the response.
Steps to Independently Build and Deploy Samples Subscriber Service
Note
For running 2 or more microservices, we recommend users to try the use case-driven approach for building and deploying as mentioned in Generate Consolidated Files for a Subset of Edge Insights for Industrial Services
Steps to Independently Build Samples Subscriber Service
Note
When switching between independent deployment of the service with and without config manager agent service dependency, one would run into issues with docker compose build
w.r.t Certificates folder existence. As a workaround, run the command sudo rm -rf Certificates
to proceed with docker compose build
.
To independently build Samples subscriber service, complete the following steps:
The downloaded source code should have a directory named Samples:
Enter into the AppContext by selecting the
<language>
and<linux_flavor>
of your choice in the following command.cd IEdgeInsights/Samples/subscriber/<language>/<linux_flavor>
NOTE:
<language>
can be eithercpp
,go
orpython
and<linux_flavor>
isubuntu
. Ensure to select<linux_flavor>
asubuntu
if the<language>
ispython
as the Python subscriber and client are supported only in Ubuntu operating systems or docker images.Copy the IEdgeInsights/build/.env file using the following command in the current folder
cp ../../../../build/.env .
NOTE: Update the HOST_IP and ETCD_HOST variables in the .env file with your system IP.
# Source the .env using the following command: set -a && source .env && set +a
Independently build
docker compose build
Steps to Independently Deploy Samples Subscriber Service
You can deploy the Samples subscriber service in any of the following two ways:
Deploy Samples Subscriber Service without Config Manager Agent Dependency
Run the following commands to deploy Samples subscriber service without Config Manager Agent dependency:
# Enter the AppContext
cd IEdgeInsights/Samples/subscriber/<language>/<linux_flavor>
Copy the IEdgeInsights/build/.env file using the following command in the current folder, if not already present.
cp ../../../../build/.env .Note: Ensure that
docker ps
is clean anddocker network ls
must not have EII bridge network.
Update .env file for the following:
1. HOST_IP and ETCD_HOST variables with your system IP.
2. `READ_CONFIG_FROM_FILE_ENV` value to `true` and `DEV_MODE` value to `true`.
Source the .env using the following command:
set -a && source .env && set +a
# Run the service
docker compose -f docker-compose.yml -f docker-compose-dev.override.yml up -d
Deploy Samples Subscriber Service with Config Manager Agent Dependency
Run the following commands to deploy Samples subscriber service with Config Manager Agent dependency:
Note
Ensure that the Config Manager Agent image present in the system. If not, build the Config Manager Agent locally when independently deploying the service with Config Manager Agent dependency.
# Enter the AppContext
cd IEdgeInsights/Samples/subscriber/<language>/<linux_flavor>
Copy the IEdgeInsights/build/.env file using the following command in the current folder, if not already present.
cp ../../../../build/.env .Note: Ensure that
docker ps
is clean anddocker network ls
doesn’t have EII bridge networks.
Update .env file for following:
1. HOST_IP and ETCD_HOST variables with your system IP.
2. `READ_CONFIG_FROM_FILE_ENV` value is set to `false`.
Copy the docker-compose.yml from IEdgeInsights/ConfigMgrAgent as docker-compose.override.yml.
cp ../../../../ConfigMgrAgent/docker-compose.yml docker-compose.override.yml
Copy the builder.py with standalone mode changes from IEdgeInsights/build directory
cp ../../../../build/builder.py .Run the builder.py in standalone mode, this will generate eii_config.json and update docker-compose.override.yml
python3 builder.py -s true
Build the service (This step is optional for building the service if not done in the
Independently buildable
step).
docker compose build
Run the service in PROD mode, execute the following command:
NOTE: Ensure to update
DEV_MODE
tofalse
in .env while running in PROD mode and source the .env using the commandset -a && source .env && set +a
.
docker compose up -d
Run the service in DEV mode, execute the following command:
NOTE: Ensure to update
DEV_MODE
totrue
in .env while running in DEV mode and source the .env using the commandset -a && source .env && set +a
.
docker compose -f docker-compose.yml -f docker-compose-dev.override.yml -f docker-compose.override.yml up -d