January 2020
Intermediate to advanced
640 pages
16h 56m
English
So far, we have created three services for our monolith that all implement the Service interface. Now, we need to introduce a supervisor for coordinating their execution and making sure that they all cleanly terminate if any of them reports an error. Let's define a new type so that we can model a group of services and add a helper Run method to manage their execution life cycle:
type Group []Service func (g Group) Run(ctx context.Context) error {...}
Now, let's break down the Run method's implementation into smaller chunks and go through each one:
if ctx == nil { ctx = context.Background() } runCtx, cancelFn := context.WithCancel(ctx) defer cancelFn()
As you can see, first, we create a ...
Read now
Unlock full access