Esempio n. 1
0
// DropService drops service.
func (s *ServiceManager) DropService(svcName string) apis.IResponse {
	s.rwLock.Lock()
	defer s.rwLock.Unlock()
	svc, ok := s.allSvcs[svcName]
	if !ok {
		return mpqerr.ERR_NO_SVC
	}
	svc.Close()
	delete(s.allSvcs, svcName)
	svcID := svc.Info().ID
	queue_info.DeleteServiceData(svcID)
	log.Debug("Service '%s' has been removed: (id:%s)", svcName, svcID)
	return resp.OK_RESPONSE
}
Esempio n. 2
0
func (s *ServiceManager) loadService(desc *queue_info.ServiceDescription) (apis.ISvc, bool) {
	if desc.Disabled {
		log.Error("Service is disabled. Skipping: %s", desc.Name)
		return nil, false
	}
	if desc.ToDelete {
		log.Warning("Service should be deleted: %s", desc.Name)
		queue_info.DeleteServiceData(desc.Name)
		return nil, false
	}
	log.Debug("Loading service data for: %s", desc.Name)

	serviceLoader, ok := GetServiceLoader(desc.SType)
	if !ok {
		log.Error("Unknown service '%s' type: %s", desc.Name, desc.SType)
		return nil, false
	}
	svcInstance, err := serviceLoader(s, desc)
	if err != nil {
		log.Error("Service '%s' was not loaded because of: %s", desc.Name, err)
		return nil, false
	}
	return svcInstance, true
}