Manifest Initiates an Event Bus to Monitor Lease Won Events
The NewService
function called from provider/manifest/service.go
subscribes to a RPC node event bus for new lease won processing.
Eventually the run
method in this package is called with a service type passed in.
func NewService(ctx context.Context, session session.Session, bus pubsub.Bus, hostnameService clustertypes.HostnameServiceClient, cfg ServiceConfig) (Service, error) {
session = session.ForModule("provider-manifest")
sub, err := bus.Subscribe()
if err != nil {
return nil, err
}
s := &service{
session: session,
bus: bus,
sub: sub,
statusch: make(chan chan<- *Status),
mreqch: make(chan manifestRequest),
activeCheckCh: make(chan isActiveCheck),
managers: make(map[string]*manager),
managerch: make(chan *manager),
lc: lifecycle.New(),
hostnameService: hostnameService,
config: cfg,
watchdogch: make(chan dtypes.DeploymentID),
watchdogs: make(map[dtypes.DeploymentID]*watchdog),
}
go s.lc.WatchContext(ctx)
go s.run()
return s, nil
}