Assumes golang, and redis are installed on the system. If there is a connection available to a redis instance running, then you may skip installing redis.
I ran my application on Ubuntu 18.04 using:
- go version go1.13.5 linux/amd64
- Redis server v=4.0.9 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=9435c3c2879311f3
To install redis on Ubuntu, run sudo apt-get install redis-server
, and on a Mac, run brew install redis
using Homebrew. The default port is :6379
for redis, which is what's in config.json
. Running redis-cli
will open a connection to the redis instance, and can confirm that you're connecting to the correct port.
Configurations are loaded at runtime for the applications, so any changes to config.json should be done before starting the services.
The next steps are to get a terminal window for each service. From the project's base directory, where the makefiles are located, run:
make publisher
make sumfinder
make meanfinder
I wrote all code under /cmd
and the makefile
. I was closely following redigo's examples for PubSubConn to establish a publish and subsribe connection to the instance of redis.
- Get docker-compose to build images of publisher and subscribers, as well as get the wiring hooked up between images. The advantage of this approach is that setup and running the application would be a single command, and everyone running the application will have the same environment.
- Increase test coverage. Most of the code is using other libraries. I did however attempt to use an interface to break up some coupling to be able to stub out methods from the redis library so that I can insert my own tests. Due to time constraints, I have left it untouched in
feature/maketestable
. - Use of dockertest library to get integration testing done on docker images.
- Adding flag to define the range of numbers generated by the publisher.
- Adding flag to define which configuration file to use, rather than expecting it to be the first argument after the program name.
- Define default values in case no configuration file is provided.