agent: remove an a branch in the AddService flow
Handle the decision to use ServiceManager in a single place. Instead of calling ServiceManager.AddService, then calling back into addServiceInternal, only call ServiceManager.AddService if we are going to use it. This change removes some small duplication and removes a branch from the AddService flow.
This commit is contained in:
parent
1ce7cdd892
commit
75b2c55291
|
@ -1912,7 +1912,7 @@ func (a *Agent) addServiceLocked(req AddServiceRequest) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if a.config.EnableCentralServiceConfig {
|
if a.config.EnableCentralServiceConfig && (req.Service.IsSidecarProxy() || req.Service.IsGateway()) {
|
||||||
return a.serviceManager.AddService(req)
|
return a.serviceManager.AddService(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,15 +122,6 @@ func (s *ServiceManager) registerOnce(args addServiceInternalRequest) error {
|
||||||
//
|
//
|
||||||
// NOTE: the caller must hold the Agent.stateLock!
|
// NOTE: the caller must hold the Agent.stateLock!
|
||||||
func (s *ServiceManager) AddService(req AddServiceRequest) error {
|
func (s *ServiceManager) AddService(req AddServiceRequest) error {
|
||||||
req.Service.EnterpriseMeta.Normalize()
|
|
||||||
|
|
||||||
// For now only proxies have anything that can be configured
|
|
||||||
// centrally. So bypass the whole manager for regular services.
|
|
||||||
if !req.Service.IsSidecarProxy() && !req.Service.IsGateway() {
|
|
||||||
req.persistServiceConfig = false
|
|
||||||
return s.agent.addServiceInternal(addServiceInternalRequest{AddServiceRequest: req})
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: replace serviceRegistration with AddServiceRequest
|
// TODO: replace serviceRegistration with AddServiceRequest
|
||||||
reg := &serviceRegistration{
|
reg := &serviceRegistration{
|
||||||
service: req.Service,
|
service: req.Service,
|
||||||
|
|
Loading…
Reference in New Issue