def read( self, logger: AirbyteLogger, config: Mapping[str, Any], catalog: ConfiguredAirbyteCatalog, state: MutableMapping[str, Any] = None) -> Iterator[AirbyteMessage]: connector_state = copy.deepcopy(state or {}) logger.info(f"Starting syncing {self.name}") # TODO assert all streams exist in the connector # get the streams once in case the connector needs to make any queries to generate them stream_instances = {s.name: s for s in self.streams(config)} for configured_stream in catalog.streams: try: stream_instance = stream_instances[ configured_stream.stream.name] yield from self._read_stream( logger=logger, stream_instance=stream_instance, configured_stream=configured_stream, connector_state=connector_state) except Exception as e: logger.exception( f"Encountered an exception while reading stream {self.name}" ) raise e logger.info(f"Finished syncing {self.name}")
def read( self, logger: AirbyteLogger, config: Mapping[str, Any], catalog: ConfiguredAirbyteCatalog, state: MutableMapping[str, Any] = None) -> Iterator[AirbyteMessage]: """Implements the Read operation from the Airbyte Specification. See https://docs.airbyte.io/architecture/airbyte-specification.""" connector_state = copy.deepcopy(state or {}) logger.info(f"Starting syncing {self.name}") # TODO assert all streams exist in the connector # get the streams once in case the connector needs to make any queries to generate them stream_instances = {s.name: s for s in self.streams(config)} with create_timer(self.name) as timer: for configured_stream in catalog.streams: try: stream_instance = stream_instances[ configured_stream.stream.name] timer.start_event(configured_stream.stream.name) yield from self._read_stream( logger=logger, stream_instance=stream_instance, configured_stream=configured_stream, connector_state=connector_state, ) timer.end_event() except Exception as e: logger.exception( f"Encountered an exception while reading stream {self.name}" ) raise e finally: logger.info(f"Finished syncing {self.name}") logger.info(timer.report()) logger.info(f"Finished syncing {self.name}")