Running the solution

We built many components over the previous two chapters, and it is now time to see them all working together. This section contains everything you need in order to get all the items running, assuming you have the environment set up properly, as described at the beginning of the previous chapter. This section assumes you have a single folder that contains the four subfolders: api, counter, twittervotes, and web.

Assuming nothing is running, take the following steps (each step in its own terminal window):

  1. In the top-level folder, start the nsqlookupd daemon:
    nsqlookupd
    
  2. In the same directory, start the nsqd daemon:
    nsqd --lookupd-tcp-address=localhost:4160
    
  3. Start the MongoDB daemon:
    mongod
    
  4. Navigate to the counter folder and build and run it:
    cd counter
    go build -o counter
    ./counter
    
  5. Navigate to the twittervotes folder and build and run it. Ensure that you have the appropriate environment variables set; otherwise, you will see errors when you run the program:
    cd ../twittervotes
    go build -o twittervotes
    ./twittervotes
    
  6. Navigate to the api folder and build and run it:
    cd ../api
    go build -o api
    ./api
    
  7. Navigate to the web folder and build and run it:
    cd ../web
    go build -o web
    ./web
    

Now that everything is running, open a browser and head to http://localhost:8081/. Using the user interface, create a poll called Moods and input the options as happy,sad,fail,success. These are common enough words that we are likely to see some relevant activity on Twitter.

Once you have created your poll, you will be taken to the view page where you will start to see the results coming in. Wait for a few seconds and enjoy the fruits of your hard work as the UI updates in real time, showing live, real-time results:

Running the solution

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.72.74