Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout promises before search request #70

Merged
merged 3 commits into from
Sep 28, 2023
Merged

Conversation

dfarr
Copy link
Member

@dfarr dfarr commented Sep 28, 2023

Rather than switch the state of "logically timedout" promises at read time, we can timeout promises prior to searching. To do this we need ensure we still create the corresponding notifications, delete subscriptions, and update the promise all in one transaction.

INSERT INTO notifications
    (id, promise_id, url, retry_policy, time, attempt)
SELECT
	id, promise_id, url, retry_policy, $1, 0
FROM
	subscriptions
WHERE
	promise_id IN (SELECT id FROM promises WHERE state = 1 AND timeout <= $1)

DELETE FROM
	subscriptions
WHERE
	promise_id IN (SELECT id FROM promises WHERE state = 1 AND timeout <= $1)

UPDATE
	promises
SET
	state = 8, completed_on = timeout
WHERE
	state = 1 AND timeout <= $1

This PR also changes the regular timeout promises coroutine to use the same logic as well as all complete promise coroutines to create notifications using the same logic.

@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

Merging #70 (fe11001) into main (318c696) will decrease coverage by 2.55%.
The diff coverage is 80.57%.

@@            Coverage Diff             @@
##             main      #70      +/-   ##
==========================================
- Coverage   73.43%   70.89%   -2.55%     
==========================================
  Files          42       42              
  Lines        4288     4247      -41     
==========================================
- Hits         3149     3011     -138     
- Misses        941     1019      +78     
- Partials      198      217      +19     
Files Coverage Δ
internal/app/coroutines/timeoutPromises.go 91.30% <100.00%> (+2.01%) ⬆️
internal/app/subsystems/aio/store/test/util.go 75.75% <ø> (ø)
internal/app/coroutines/readPromise.go 53.16% <0.00%> (-1.27%) ⬇️
internal/app/coroutines/searchPromises.go 89.47% <96.15%> (+0.43%) ⬆️
internal/app/coroutines/cancelPromise.go 73.54% <92.30%> (-15.16%) ⬇️
internal/app/coroutines/completePromise.go 73.88% <92.30%> (-14.95%) ⬇️
internal/app/coroutines/createPromise.go 69.34% <0.00%> (-2.19%) ⬇️
internal/app/coroutines/rejectPromise.go 72.90% <92.30%> (-3.94%) ⬇️
internal/app/coroutines/resolvePromise.go 73.37% <92.30%> (-15.26%) ⬇️
internal/app/coroutines/timeoutPromise.go 85.18% <81.81%> (-4.51%) ⬇️
... and 2 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dfarr dfarr merged commit af6f469 into main Sep 28, 2023
3 of 4 checks passed
@dfarr dfarr deleted the feature/timeout-promises branch September 28, 2023 16:05
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