PROP-57 - Add status filter for proplets and jobs#180
Open
JeffMboya wants to merge 14 commits intoabsmach:mainfrom
Open
PROP-57 - Add status filter for proplets and jobs#180JeffMboya wants to merge 14 commits intoabsmach:mainfrom
JeffMboya wants to merge 14 commits intoabsmach:mainfrom
Conversation
EncodeError now maps apiutil.ErrValidation and pkgerrors.ErrInvalidValue to HTTP 400. Invalid status values in ListProplets and ListJobs wrap ErrInvalidValue so they propagate through EncodeError as Bad Request rather than falling through to Internal Server Error.
ListTasks does not support status filtering. The endpoint now rejects any non-empty status query param with 400 Bad Request instead of silently ignoring it.
Adds Proplet and PropletPage SDK types, and ListProplets(offset, limit, status) to the SDK interface and propSDK implementation. Status values "active" and "inactive" are URL-encoded before being appended to the query string.
Importing net/url for url.QueryEscape also required renaming the local url variables in all other SDK task functions to avoid shadowing the imported package (caught by gocritic importShadow).
Covers: active/inactive filter, invalid status returns error, pagination with filter applied, Interrupted tasks mapping to the failed filter, and Scheduled tasks mapping to the running filter.
The error now wraps ErrInvalidValue so the message starts with "invalid value provided" rather than the old literal prefix.
…bState guarantees
Add ListByAlive to PropletRepository across all four backends (Postgres, SQLite, Badger, Memory) so GET /proplets?status= filters at the repo layer instead of scanning all proplets into memory in the service. Export proplet.AliveTimeout so the service can compute the liveness cutoff without duplicating the constant. Remove listAllProplets helper.
Cap the Badger in-process filter scan at 100k entries to prevent unbounded memory growth. Wrap Postgres ListByAlive in a REPEATABLE READ transaction so COUNT and SELECT see the same snapshot. Replace the SQLite batch-loop with a single transactional full-table scan to eliminate the same COUNT/SELECT divergence risk.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What type of PR is this?
Feature - status-based filtering for proplets and jobs.
What does this do?
GET /proplets?status=active|inactivefilters by livenessGET /jobs?status=pending|running|completed|failedfilters by stateGET /tasksreturns 400 if?status=is passedListPropletsandListJobsaccept optional status paramWhich issue(s) does this PR fix/relate to?
Have you included tests for your changes?
Yes - service-level and filter-pagination tests added.
Did you document any new/modified features?
No - API is self-describing via query param validation errors.