Skip to content

Feature/dynamic polling - #31

Merged
karelyrodri merged 4 commits into
v0.1.1from
feature/dynamic_polling
Mar 6, 2026
Merged

Feature/dynamic polling#31
karelyrodri merged 4 commits into
v0.1.1from
feature/dynamic_polling

Conversation

@karelyrodri

Copy link
Copy Markdown
Collaborator

No description provided.

Implement comprehensive polling infrastructure for long-running operations:

Features:
- Add support_polling parameter to @validated decorator
- Extract pollRequestId from request body before validation
- Track operation progress via DynamoDB poll_status table
- Implement PollStatusHandler logging to update poll records in real-time
- Add thread-local request context for poll tracking
- Rate-limit DynamoDB updates (5 second minimum interval)
- Auto-finalize poll status on success/failure with cleanup
- Fail-safe design: all polling operations wrapped in try/except

New functions:
- _init_poll_status_record(): Initialize poll tracking in DynamoDB
- _finalize_poll_status_record(): Update final status and cleanup
- activate_poll_tracking(): Enable poll logging for current request
- deactivate_poll_tracking(): Disable poll logging
- get_active_poll_request_id(): Get current poll request ID
- PollStatusHandler: Custom logging handler for DynamoDB updates

Testing:
- Add 16 new tests for polling functionality
- Add 11 new tests for logger poll status handler
- Achieve 100% test coverage (888 tests passing)
- Test all exception handlers and fail-safe behaviors

DynamoDB Schema:
- requestId (partition key): Unique poll request ID
- user (sort key): Username from auth claims
- status: processing/completed/failed
- lastLog: Most recent log message
- lastLogLevel: Log level (INFO/ERROR/etc)
- ttl: Auto-cleanup after 14 days
- Added calls to `deactivate_poll_tracking()` in the `validated` function to ensure poll tracking is disabled right after the finalization of poll status.
- This change prevents any subsequent logs from overwriting the completed status, improving the accuracy of logging during polling operations.
- Removed the `operation` parameter from `activate_poll_tracking` and related functions to streamline the API.
- Updated logging behavior to ensure that the poll status record remains in DynamoDB for frontend retrieval, rather than being deleted after finalization.
- Adjusted tests to reflect these changes, ensuring accurate assertions regarding poll status record handling.
@karelyrodri
karelyrodri merged commit 97d02d8 into v0.1.1 Mar 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant