Putting everything together

The main package serves as the entry point for our application. It exposes the configuration options for the various services as command-line flags and takes care of the following:

The runMain method implements the main loop of the application:

As shown in the preceding code, the first line instantiates all the required services and adds them to a Group. Then, a new cancelable context is created and is used to invoke the group's (blocking) Run method.