Add Asynchronous Connection Pooling Support to PostgresChatMessageHistory #130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for asynchronous connection pooling in the
PostgresChatMessageHistory
class, addressing issues #122 and #129Changes Made:
PostgresChatMessageHistory
:conn_pool
parameter to accept anAsyncConnectionPool
instance.__init__
method to includeconn_pool
and reordered parameters for improved usability.session_id
andtable_name
can be passed as keyword arguments.aget_messages
andaadd_messages
to utilize the connection pool when provided.async_connection
to ensure backward compatibility.test_async_chat_history_with_pool
intests/unit_tests/test_chat_histories.py
to verify the new functionality.PostgresChatMessageHistory
with an asynchronous connection pool.conn_pool
parameter.Example Usage:
Testing:
Added a new test
test_async_chat_history_with_pool
intests/unit_tests/test_chat_histories.py
:Ensured all existing tests pass, maintaining backward compatibility.
Documentation:
__init__
method.Notes:
sync_connection
orasync_connection
continues to work without modifications.Related Issues:
PostgresChatMessageHistory
with async connections when usingRunnableWithMessageHistory
? #122