Skip to content

Commit

Permalink
Single Client Reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiadt committed Aug 30, 2024
1 parent 1692d98 commit f23110f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nodestream/databases/debounced_ingest_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@ async def flush(self):
for hook in self.hooks_saved_for_after_ingest:
await self.executor.execute_hook(hook)
self.hooks_saved_for_after_ingest.clear()

async def finish(self):
"""Close connector by calling finish method from Step"""
await self.executor.finish()
4 changes: 4 additions & 0 deletions nodestream/databases/ingest_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ async def perform_ttl_operation(self, config: "TimeToLiveConfiguration"):
async def flush(self):
"""Flush any pending operations to the database."""
pass

async def finish(self):
"""Close connector by calling finish method from Step"""
self.connector.finish()
3 changes: 3 additions & 0 deletions nodestream/databases/query_executor_with_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ async def perform_ttl_op(self, config: TimeToLiveConfiguration):
async def execute_hook(self, hook: IngestionHook):
await self.inner.execute_hook(hook)
get_context().increment_stat(HOOK_STAT)

async def finish(self):
await self.inner.finish()
5 changes: 5 additions & 0 deletions nodestream/databases/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ async def write_record(self, ingestible):
self.pending_records += 1
if self.pending_records >= self.batch_size:
await self.flush()

async def finish(self):
"""Close connector by calling finish method from Step"""
await self.flush()
await self.ingest_strategy.finish()

0 comments on commit f23110f

Please sign in to comment.