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

Refactor Idempotency logic to reduce boilerplate and increase code readability #1410

Open
3 tasks
peterbroadhurst opened this issue Sep 28, 2023 · 1 comment
Open
3 tasks
Labels
enhancement New feature or request

Comments

@peterbroadhurst
Copy link
Contributor

peterbroadhurst commented Sep 28, 2023

See detailed discussion in #1406

Suggested work

  • Combine txHelper utility into operations manager
    • Transactions are really grouping constructs of operations, and tracking the events for async completion
    • There is weirdness that the operations helpers do not have direct access to the idempotencyKey
    • There is a lot of boilerplate in other packages, joining together txHandler and operations functions
  • Merge the SubmitNewTransaction and ResubmitOperations functions. Return options are:
    • There is no idempotency key, here's a shiny new TX
    • We've never stored a TX for this idempotency key, here's a shiny new TX
    • TX already existed for idempotency key all done now - please return without error to the user
    • TX was stored, but no operations were stored - here's the existing transaction ID
    • All operations in the TX already reached Pending (or later), 409 to your user
    • Something else went wrong
  • (Separable) Update idempotency input handling to reject re-submit with different inputs
    • Scenario:
      1. Submit with input1 and idem1, and get to a point of Initialized operations
      2. Encounter failure that is not handled via internal retry and returns an error to you
      3. Re-submit the API call, but this time with input2 and idem1
      4. Internally FF Core already stored the operations, so re-submits them with input1 (not input2)
      5. Transaction completes with input1 - we ignored the input2 you provided
    • Improved behavior:
      • Return an error stating that input2 is not the same as input1
      • Requires per-input handling to detect the operation inputs are the same or not
@Chengxuan
Copy link
Contributor

@peterbroadhurst

All operations in the TX already reached Pending (or later), 409 to your user

Should this be true for operation requests that have identical payload with what's recorded for a given idempotency key?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants