Solutions

LE NATS Pub Sub

2min

Overview

Document image


Running the application using the downloaded Tar File

  1. After Checkout, a tar.gz file is expected to be downloaded
  2. Log in to your LitmusEdge, Navigate to Applications -> Images
  3. Click on Upload Image and upload the tar file there
  4. Once uploaded successfully, Navigate to System -> Tokens
    1. Either use an already created Rest API key, or
    2. Create Rest API token and keep it handy
  5. Navigate back to Applications -> Containers and enter the following command there:
    1. docker run -e "NATS_HOST=<0.0.0.0>" -e "API_TOKEN=<token>" -e "SUB_TOPICS=<topic>" -e WINDOW_SIZE=5 -e "PUB_TOPICS=<result>" <image>:<tag>
    2. Use the API token as created from previous step
    3. Here we are asking the container to subscribe to a specific topic, perform some calculations on it and publish to another topic, with API token passed as an environment variable, and using imgName and tagName respectively
    4. Window size is defined for performing the specific calculations
    5. The calculations done on the subscribed topic are:
      1. Mean of all values in the mentioned window
      2. Variance of all values in the mentioned window
      3. Standard Deviation of all values in the mentioned window
    6. The calculations are specific, and are meant to be used as an example template. Full customization of the calculation on the fly (e.g changing it to some other calculation at runtime) is not yet supported
  6. Navigate to Flows manger or Analytics to view the output of on the topic <result>