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:
- Instantiating the appropriate data store implementations for the link graph (memory or CockroachDB) and text indexer (memory or Elasticsearch)
- Instantiating the various application services with the correct configuration options
The runMain method implements the main loop of the application:
func runMain(logger *logrus.Entry) error { svcGroup, err := setupServices(logger) if err != nil { return err } ctx, cancelFn := context.WithCancel(context.Background()) defer cancelFn() return svcGroup.Run(ctx) }
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.