Book Image

Go Programming Blueprints

By : Mat Ryer
Book Image

Go Programming Blueprints

By: Mat Ryer

Overview of this book

Table of Contents (17 chapters)
Go Programming Blueprints
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Running our solution


It's time to see our code in action. Be sure to have nsqlookupd, nsqd, and mongod running in separate terminal windows with:

nsqlookupd
nsqd --lookupd-tcp-address=127.0.0.1:4160
mongod --dbpath ./db

If you haven't already done so, make sure the twittervotes program is running too. Then in the counter folder, build and run our counting program:

go build -o counter
./counter

You should see periodic output describing what work counter is doing, such as:

No new votes, skipping database update
Updating database...
map[win:2 happy:2 fail:1]
Finished updating database...
No new votes, skipping database update
Updating database...
map[win:3]
Finished updating database...

Tip

The output will of course vary since we are actually responding to real live activity on Twitter.

We can see that our program is receiving vote data from NSQ, and reports to be updating the database with the results. We can confirm this by opening the MongoDB shell and querying the poll data to see if the...