Skip to content

Commit

Permalink
Actually make use of Error Monitor and add configuration option for it
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-shelkovnikov committed Jul 23, 2024
1 parent fda81d2 commit 19d9fcc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions connectors/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def _default_config():
"max_consecutive_errors": 10,
"max_error_rate": 0.15,
"error_window_size": 100,
"error_queue_size": 10,
},
"max_concurrent_content_syncs": 1,
"max_concurrent_access_control_syncs": 1,
Expand Down
4 changes: 3 additions & 1 deletion connectors/es/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,9 @@ def _extractor_task_running(self):

async def cancel(self):
if self._sink_task_running():
self._logger.info(f"Canceling the Sink task: {self._sink_task.get_name()}")
self._logger.info(
f"Canceling the Sink task: {self._sink_task.get_name()}" # pyright: ignore
)
self._sink_task.cancel()
else:
self._logger.debug(
Expand Down
27 changes: 27 additions & 0 deletions tests/test_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,16 @@ async def test_extractor_put_doc():
doc = {"id": 123}
queue = Mock()
queue.put = AsyncMock()
<<<<<<< HEAD
extractor = Extractor(None, queue, INDEX, error_monitor=Mock())
=======
extractor = Extractor(
None,
queue,
INDEX,
error_monitor=Mock()
)
>>>>>>> b47bf686 (Actually make use of Error Monitor and add configuration option for it)

await extractor.put_doc(doc)
queue.put.assert_awaited_once_with(doc)
Expand Down Expand Up @@ -1388,7 +1397,16 @@ async def test_force_canceled_extractor_put_doc():
doc = {"id": 123}
queue = Mock()
queue.put = AsyncMock()
<<<<<<< HEAD
extractor = Extractor(None, queue, INDEX, error_monitor=Mock())
=======
extractor = Extractor(
None,
queue,
INDEX,
error_monitor=Mock()
)
>>>>>>> b47bf686 (Actually make use of Error Monitor and add configuration option for it)

extractor.force_cancel()
with pytest.raises(ForceCanceledError):
Expand Down Expand Up @@ -1595,7 +1613,16 @@ def _put_side_effect(value):
# instances
doc_generator = AsyncIterator([(doc, None, "") for doc in docs_from_source])

<<<<<<< HEAD
extractor = Extractor(es_client, queue, INDEX, error_monitor=Mock())
=======
extractor = Extractor(
es_client,
queue,
INDEX,
error_monitor=Mock()
)
>>>>>>> b47bf686 (Actually make use of Error Monitor and add configuration option for it)

await extractor.run(doc_generator, JobType.FULL)

Expand Down

0 comments on commit 19d9fcc

Please sign in to comment.