Sample Subscriber Apps ====================== Subscriber apps consists of the following: C++ Subscriber -------------- The C++ subscriber and client are supported in Ubuntu and Alpine operating systems or docker images. The C++ subscriber runs in the independent containers ``ia_ubuntu_cpp_sample_sub`` and ``ia_alpine_cpp_sample_sub`` respectively. Go Subscriber ------------- The Go subscriber and client are supported in Ubuntu and Alpine operating systems or docker images. The Go subscriber runs in the independent containers ``ia_ubuntu_go_sample_sub`` and ``ia_alpine_go_sample_sub`` respectively. 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 the ``msgbus`` 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 ```` and ```` of your choice in the following command. .. code-block:: sh cd IEdgeInsights/Samples/subscriber// .. **NOTE**\ : ```` can be either ``cpp``\ , ``go`` or ``python`` and ```` can be either ``alpine`` or ``ubuntu``. Ensure to select ```` as ``ubuntu`` if the ```` is ``python`` 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 .. code-block:: sh cp ../../../../build/.env . .. **NOTE**\ : Update the HOST_IP and ETCD_HOST variables in the .env file with your system IP. .. code-block:: sh # Source the .env using the following command: set -a && source .env && set +a #. Independently build .. code-block:: sh 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: .. code-block:: sh # Enter the AppContext cd IEdgeInsights/Samples/subscriber// .. Copy the IEdgeInsights/build/.env file using the following command in the current folder, if not already present. .. code-block:: sh cp ../../../../build/.env . **Note:** Ensure that ``docker ps`` is clean and ``docker network ls`` must not have EII bridge network. .. code-block:: 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 .. code-block:: sh # 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. .. code-block:: sh # Enter the AppContext cd IEdgeInsights/Samples/subscriber// .. Copy the IEdgeInsights/build/.env file using the following command in the current folder, if not already present. .. code-block:: sh cp ../../../../build/.env . **Note:** Ensure that ``docker ps`` is clean and ``docker network ls`` doesn't have EII bridge networks. .. code-block:: 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. .. code-block:: sh cp ../../../../ConfigMgrAgent/docker-compose.yml docker-compose.override.yml .. Copy the builder.py with standalone mode changes from IEdgeInsights/build directory .. code-block:: sh cp ../../../../build/builder.py . Run the builder.py in standalone mode, this will generate eii_config.json and update docker-compose.override.yml .. code-block:: sh python3 builder.py -s true .. Build the service (This step is optional for building the service if not done in the ``Independently buildable`` step). .. code-block:: sh docker-compose build .. Run the service in PROD mode, execute the following command: **NOTE**\ : Ensure to update ``DEV_MODE`` to ``false`` in .env while running in PROD mode and source the .env using the command ``set -a && source .env && set +a``. .. code-block:: sh docker-compose up -d .. Run the service in DEV mode, execute the following command: **NOTE**\ : Ensure to update ``DEV_MODE`` to ``true`` in .env while running in DEV mode and source the .env using the command ``set -a && source .env && set +a``. .. code-block:: sh docker-compose -f docker-compose.yml -f docker-compose-dev.override.yml -f docker-compose.override.yml up -d