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

Convert more callback handlers to be namespace-specific #874

Merged
merged 7 commits into from
Jun 24, 2022

Conversation

awrichar
Copy link
Contributor

Part of FIR-12.
Follow-up to #863.

Only the blockchain plugin remains, and will need to be addressed after #865.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Add some utilities and avoid unpacking things more than once.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
These handlers are no-ops, but the signature should match other plugins.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2022

Codecov Report

Merging #874 (aac130d) into main (45127ca) will increase coverage by 0.00%.
The diff coverage is 97.26%.

@@           Coverage Diff           @@
##             main     #874   +/-   ##
=======================================
  Coverage   99.96%   99.96%           
=======================================
  Files         299      300    +1     
  Lines       19483    19504   +21     
=======================================
+ Hits        19477    19498   +21     
  Misses          5        5           
  Partials        1        1           
Impacted Files Coverage Δ
internal/identity/tbd/tbd.go 90.00% <0.00%> (ø)
internal/sharedstorage/ipfs/ipfs.go 97.50% <0.00%> (ø)
internal/tokens/fftokens/fftokens.go 99.55% <ø> (-0.45%) ⬇️
internal/database/postgres/postgres.go 100.00% <100.00%> (ø)
internal/database/sqlcommon/sqlcommon.go 100.00% <100.00%> (ø)
internal/database/sqlite3/sqlite3.go 100.00% <100.00%> (ø)
internal/dataexchange/ffdx/dxevent.go 100.00% <100.00%> (ø)
internal/dataexchange/ffdx/ffdx.go 100.00% <100.00%> (ø)
internal/events/batch_pin_complete.go 100.00% <100.00%> (ø)
internal/events/dx_callbacks.go 100.00% <100.00%> (ø)
... and 41 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 45127ca...aac130d. Read the comment docs.

err = json.Unmarshal([]byte(msg.Message), &wrapper)
switch {
case err != nil:
err = fmt.Errorf("invalid transmission from peer '%s': %s", msg.Sender, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering why these aren't translated errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error is just logged below (this method never returns errors). I could still localize if you think there's value.


if err == nil {
if namespace == "" && msg.RequestID != "" {
namespace, _, _ = core.ParseNamespacedOpID(h.ctx, msg.RequestID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Noting that if the namespace here is empty/invalid, we catch it in the DXEvent callback (hence no need for error checking here)

}
return fmt.Errorf("unknown namespace on event '%s'", event.EventID())
Copy link
Contributor

Choose a reason for hiding this comment

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

Another untranslated error

Copy link
Contributor Author

@awrichar awrichar Jun 24, 2022

Choose a reason for hiding this comment

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

Pushed a tweak to address this and make it clear it's just logged and not returned

@@ -224,6 +211,7 @@ func (em *eventManager) privateBlobReceived(dx dataexchange.Plugin, event dataex
}
if br.Namespace != em.namespace {
log.L(em.ctx).Debugf("Ignoring blob from different namespace '%s'", br.Namespace)
event.Ack() // Still confirm the event
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we guaranteed to only pass the event to a single DX Callback handler? ... if not, what is the implication that event.Ack() could be called multiple times?

Copy link
Contributor

Choose a reason for hiding this comment

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

... I remember we made changes to the event ack interface to FFDX, but I can't remember if that included an ID in the ack such that a duplicate was ignored. Feel like maybe I should check that

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

Approved - with a couple of comments on translation of errors to consider.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
@awrichar awrichar requested a review from shorsher as a code owner June 24, 2022 15:38
@awrichar awrichar merged commit 741263c into hyperledger:main Jun 24, 2022
@awrichar awrichar deleted the callbacks branch June 24, 2022 15:49
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.

3 participants