Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
## 2026-06-10 - [Stream] Faster Cross-Model Validation with from_attributes
**Learning:** When validating a Pydantic model using data from another Pydantic model (e.g., transforming a `SourceItem` to a `DestinationItem`), using `Model.model_validate(other_model, from_attributes=True)` is significantly faster and more memory-efficient than `Model.model_validate(other_model.model_dump())`. It bypasses the overhead of serializing the source model into an intermediate Python dictionary.
**Action:** Use `from_attributes=True` for efficient model-to-model transformations, especially in high-throughput data processing paths like DynamoDB Streams or SQS batch processing.

## 2026-06-11 - [General] Optimized AWS Service Clients with botocore.config.Config
**Learning:** Configuring Boto3 clients with `tcp_keepalive=True` and `retries={"max_attempts": 3, "mode": "standard"}` in the `botocore.config.Config` significantly improves connection resilience and reduces latency in AWS Lambda. TCP keep-alive ensures that connections in the pool remain active, avoiding the overhead of re-establishing TCP/TLS handshakes, while the 'standard' retry mode provides more robust exponential backoff.
**Action:** Always use a centralized `botocore.config.Config` when instantiating Boto3 resources or clients in Lambda templates to optimize performance and reliability.
5 changes: 4 additions & 1 deletion templates/queue.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from boto3 import client
from botocore.config import Config


class Queue:
Expand All @@ -11,8 +12,10 @@ def __init__(self, queue_url: str, region_name: str = "us-east-1") -> None:
queue_url: The URL of the SQS queue.
region_name: The region to use.
"""
# Optimize connection resilience and performance with TCP keepalive and standard retries
config = Config(tcp_keepalive=True, retries={"max_attempts": 3, "mode": "standard"})
self._queue_url = queue_url
self._client = client("sqs", region_name=region_name)
self._client = client("sqs", region_name=region_name, config=config)

def publish(self, message: str) -> None:
"""Publish a processed message to SQS.
Expand Down
5 changes: 4 additions & 1 deletion templates/repository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from boto3 import resource
from botocore.config import Config


class Repository:
Expand All @@ -12,7 +13,9 @@ def __init__(self, table_name: str) -> None:
Args:
table_name: The name of the DynamoDB table to operate on.
"""
self._table = resource("dynamodb").Table(table_name)
# Optimize connection resilience and performance with TCP keepalive and standard retries
config = Config(tcp_keepalive=True, retries={"max_attempts": 3, "mode": "standard"})
self._table = resource("dynamodb", config=config).Table(table_name)

def get_item(self, item_id: str) -> dict | None:
"""Retrieve an item by its ID.
Expand Down