def get_version(self): service = config.get_service() version = self._get_version_from_pkg(service) if version is None: version = self._get_version_from_file(service) return version or 'UNKNOWN'
def _set_grpc_method(self): grpc_servicer = self._get_grpc_servicer() for f_name, f_object in inspect.getmembers( self.__class__, predicate=inspect.isfunction): if hasattr(grpc_servicer, f_name): setattr(self, f_name, self._grpc_method(f_object, config.get_service()))
def serve(): # Load scheduler config # Create Scheduler threads # start Scheduler set_logger() conf = config.get_global() server = Server(config.get_service(), conf) server.start()
def get_info(self, name, *args, **kwargs): service = config.get_service() try: info_module = _get_module(service, 'info') return getattr(info_module, name)(*args, **kwargs) except ERROR_BASE as e: raise e except Exception as e: raise ERROR_LOCATOR(name=name, reason=e, _meta={'type': 'info'})
def get_manager(self, name, **kwargs): service = config.get_service() try: manager_module = _get_module(service, 'manager') return getattr(manager_module, name)(self.transaction, **kwargs) except ERROR_BASE as e: raise e except Exception as e: raise ERROR_LOCATOR(name=name, reason=e, _meta={'type': 'manager'})
def get_service(self, name, metadata={}): service = config.get_service() try: service_module = _get_module(service, 'service') return getattr(service_module, name)(metadata) except ERROR_BASE as e: raise e except Exception as e: raise ERROR_LOCATOR(name=name, reason=e, _meta={'type': 'service'})
def serve(): # Load scheduler config # Create Scheduler threads # start Scheduler conf = config.get_global() # Enable logging configuration if conf.get('SET_LOGGING', True): set_logger() server = Server(config.get_service(), conf) server.start()
def get_actuator(self, name, *args, **kwargs): service = config.get_service() actuator = self._load_actuator('core', name, *args, **kwargs) try: service_actuator = self._load_actuator(service, name, *args, **kwargs) if issubclass(service_actuator.__class__, actuator.__class__): actuator = service_actuator except Exception as e: message = getattr(e, 'message', e) _LOGGER.warning(f'Actuator Load Error: {message}') return actuator
def get_model(self, name): service = config.get_service() try: model_module = _get_module(service, 'model') model = getattr(model_module, name) model.connect() return model except ERROR_BASE as e: raise e except Exception as e: raise ERROR_LOCATOR(name=f'{name} Model', reason=e, _meta={'type': 'info'})
def get_connector(self, name, **kwargs): service = config.get_service() connector_conf = config.get_connector(name) try: connector_module = _get_module(service, 'connector') return getattr(connector_module, name)(self.transaction, connector_conf, **kwargs) except ERROR_BASE as e: raise e except Exception as e: raise ERROR_LOCATOR(name=name, reason=e, _meta={'type': 'connector'})
def update_status(self, status): service_name = config.get_service() self.set(service_name, status)