FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: Make keep-alive timeout configurable for async DynamoDB connections by sebastjaeger · Pull Request #5167 · feast-dev/feast · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
24 changes: 19 additions & 5 deletions sdk/python/feast/infra/online_stores/dynamodb.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class DynamoDBOnlineStoreConfig(FeastConfigBaseModel):
max_pool_connections: int = 10
"""Max number of connections for async Dynamodb operations"""

keepalive_timeout: float = 12.0
"""Keep-alive timeout in seconds for async Dynamodb connections."""


class DynamoDBOnlineStore(OnlineStore):
"""
Expand All @@ -97,7 +100,9 @@ class DynamoDBOnlineStore(OnlineStore):

async def initialize(self, config: RepoConfig):
await _get_aiodynamodb_client(
config.online_store.region, config.online_store.max_pool_connections
config.online_store.region,
config.online_store.max_pool_connections,
config.online_store.keepalive_timeout,
)

async def close(self):
Expand Down Expand Up @@ -272,7 +277,9 @@ async def online_write_batch_async(
for entity_key, features, timestamp, _ in _latest_data_to_write(data)
]
client = await _get_aiodynamodb_client(
online_config.region, config.online_store.max_pool_connections
online_config.region,
online_config.max_pool_connections,
online_config.keepalive_timeout,
)
await dynamo_write_items_async(client, table_name, items)

Expand Down Expand Up @@ -377,7 +384,9 @@ def to_tbl_resp(raw_client_response):
entity_id_batches.append(entity_id_batch)

client = await _get_aiodynamodb_client(
online_config.region, online_config.max_pool_connections
online_config.region,
online_config.max_pool_connections,
online_config.keepalive_timeout,
)
response_batches = await asyncio.gather(
*[
Expand Down Expand Up @@ -536,14 +545,19 @@ def _get_aioboto_session():
return _aioboto_session


async def _get_aiodynamodb_client(region: str, max_pool_connections: int):
async def _get_aiodynamodb_client(
region: str, max_pool_connections: int, keepalive_timeout: float
):
global _aioboto_client
if _aioboto_client is None:
logger.debug("initializing the aiobotocore dynamodb client")
client_context = _get_aioboto_session().create_client(
"dynamodb",
region_name=region,
config=AioConfig(max_pool_connections=max_pool_connections),
config=AioConfig(
max_pool_connections=max_pool_connections,
connector_args={"keepalive_timeout": keepalive_timeout},
),
)
context_stack = contextlib.AsyncExitStack()
_aioboto_client = await context_stack.enter_async_context(client_context)
Expand Down

Back | FazBrowse Home | New Git URL