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

feat: reward user endpoint retry mechanism #325

Merged
merged 12 commits into from
Apr 2, 2024
Merged

Conversation

Muparadzi
Copy link
Collaborator

creates idempotencykey table with guid, created timestamp & status.

if key doesn't exist or status != completed, will retry the reward.
else returns no reward

@Muparadzi Muparadzi requested review from or2e and namidaka March 18, 2024 11:52
@or2e or2e linked an issue Mar 18, 2024 that may be closed by this pull request
@Muparadzi Muparadzi requested a review from or2e March 20, 2024 12:19
or2e
or2e previously approved these changes Mar 20, 2024
Comment on lines 23 to 25

namespace Crpg.Persistence.Migrations
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scoped namespace

Comment on lines 21 to 22

#nullable disable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@verdie-g
Copy link
Collaborator

verdie-g commented Mar 24, 2024

Just passing by 👋 That can also be resolved by catching DbUpdateConcurrencyException in UpdateGameUsersCommand and retrying there. I didn't do it because I wasn't sure how to clear the DbContext.

Comment on lines 113 to 121
private async Task<IdempotencyKey?> LoadIdempotencyKey(Guid key, CancellationToken cancellationToken)
{
var idempotencyKey = await _db.IdempotencyKeys
.Where(ik => ik.Key == key.ToString())
.FirstOrDefaultAsync(cancellationToken);

return idempotencyKey;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to the main function. There is no reuse of this method. It just makes it harder to spot issues in the main method.

@namidaka
Copy link
Collaborator

Can you also fix the multiple warnings you introduced?

@Muparadzi Muparadzi requested a review from namidaka April 1, 2024 21:55
@namidaka namidaka merged commit 3ed8560 into master Apr 2, 2024
4 checks passed
@namidaka namidaka deleted the idempotency-check branch April 2, 2024 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retry mechanism in reward endpoint
4 participants