...

/

Updating the Composition Root of Each Module

Updating the Composition Root of Each Module

Explore the streamlining module initialization to facilitate standalone microservice deployment while retaining flexibility for monolithic architecture.

We'll cover the following...

Every module uses a Startup() method to initialize itself to run with the resources that the monolith has provided. Our update will be a small one. We will be moving the code within Startup() to a new Root() function. Then, we create a call to it from Startup() and it will be as though nothing has changed:

func (m *Module) Startup(
ctx context.Context, mono system.Service,
) (err error) {
return Root(ctx, mono)
}
func Root(
ctx context.Context, svc system.Service,
) (err error) {
// ...
}
Calling a new Root() function from Startup()

This simple change will allow us to reuse the composition root code for the other method of running the module, running it as a standalone ...