We have built many components over the last two chapters, and it is now time to see them all working together. This section contains everything you need 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 four subfolders: api
, counter
, twittervotes
, and web
.
Assuming nothing is running, take the following steps (each step in its own terminal window):
nsqlookupd
daemon:nsqlookupd
nsqd
daemon:nsqd --lookupd-tcp-address=localhost:4160
mongod
counter
folder and build and run it:cd counter go build –o counter ./counter
twittervotes
folder and build and run it. Be sure 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
api
folder and build and run it:cd ../api go build –o api ./api
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,and 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.