def _connect_core(self): """Connect to core api""" if self.__core_channel is None: self.__core_channel = grpc.insecure_channel(self.core_url) self._core_service_stub = CoreServiceStub(self.__core_channel) self._job_service_stub = JobServiceStub(self.__core_channel) self._dataset_service_stub = DatasetServiceStub( self.__core_channel)
def mock_server(servicer): """Instantiate a helloworld server and return a stub for use in tests""" server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) add_JobServiceServicer_to_server(servicer, server) port = server.add_insecure_port("[::]:0") server.start() try: with grpc.insecure_channel("localhost:%d" % port) as channel: yield JobServiceStub(channel) finally: server.stop(None)
def _job_service(self): """ Creates or returns the gRPC Feast Job Service Stub Returns: JobServiceStub """ if not self._job_service_stub: channel = create_grpc_channel( url=self._config.get(CONFIG_JOB_SERVICE_URL_KEY), enable_ssl=self._config.getboolean( CONFIG_JOB_SERVICE_ENABLE_SSL_KEY), enable_auth=self._config.getboolean(CONFIG_ENABLE_AUTH_KEY), ssl_server_cert_path=self._config.get( CONFIG_JOB_SERVICE_SERVER_SSL_CERT_KEY), auth_metadata_plugin=self._auth_metadata, timeout=self._config.getint( CONFIG_GRPC_CONNECTION_TIMEOUT_DEFAULT_KEY), ) self._job_service_service_stub = JobServiceStub(channel) return self._job_service_service_stub
def _job_service(self): """ Creates or returns the gRPC Feast Job Service Stub Returns: JobServiceStub """ # Don't try to initialize job service stub if the job service is disabled if not self._use_job_service: return None if not self._job_service_stub: channel = create_grpc_channel( url=self.config.get(opt.JOB_SERVICE_URL), enable_ssl=self.config.getboolean(opt.JOB_SERVICE_ENABLE_SSL), enable_auth=self.config.getboolean(opt.ENABLE_AUTH), ssl_server_cert_path=self.config.get( opt.JOB_SERVICE_SERVER_SSL_CERT), auth_metadata_plugin=self._feast._auth_metadata, timeout=self.config.getint(opt.GRPC_CONNECTION_TIMEOUT), ) self._job_service_service_stub = JobServiceStub(channel) return self._job_service_service_stub