Operation handling for reliable receipts #1637
Draft
+192
−65
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.
Work in Progress but has been tested e2e, need to write unit tests
Proposed changes
Add a new function in the Operation Handler called
BulkOperationUpdates
that takes in a series of OperationUpdate and will notify the submitter when the TX transaction has been committed to the database.This is important for blockchain plugins that want to preserve ordering of receipts and updating the operation before acknowledging to the blockchain connector that FireFly has accepted those receipts.
Reasons why I went this way:
idempotency key
is the Operation ID so correlation is easy in the blockchain plugin between the receipt and the operationAnother approach is simply to use the
onComplete
handler on the OperationUpdate which is executed when it's committed but it's granular to each updateKey part of the code to looks at
doBatchUpdateWithRetry
runs in aretry.Do
and in a DB RunAsGroup, it retries forever seefirefly/internal/operations/operation_updater.go
Lines 184 to 199 in c7e6058
Update worker get picked based on operation ID here
firefly/internal/operations/operation_updater.go
Line 90 in c7e6058
Workers call
doBatchUpdateWithRetry
after timeout or reached a limit to writefirefly/internal/operations/operation_updater.go
Lines 172 to 180 in c7e6058
Contributes to #1622
Example Blockchain plugin code that has a durable websocket communication:
Types of changes
Please make sure to follow these points
< issue name >
egAdded links in the documentation
.