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

Breaking: Full support for websocket-based notifications and eol'ed http notifications #279

Merged
merged 1 commit into from
Jul 7, 2016

Conversation

gip
Copy link
Contributor

@gip gip commented Jun 29, 2016

@codecov-io
Copy link

codecov-io commented Jun 29, 2016

Current coverage is 91.41%

Merging #279 into master will decrease coverage by 0.57%

@@             master       #279   diff @@
==========================================
  Files            52         43     -9   
  Lines          1661       1328   -333   
  Methods         230        182    -48   
  Messages          0          0          
  Branches        278        226    -52   
==========================================
- Hits           1528       1214   -314   
+ Misses          133        114    -19   
  Partials          0          0          

Powered by Codecov. Last updated by 062dacd...d3215fb

@@ -177,6 +179,13 @@ function * subscribeTransfers () {
})

this.websocket.on('close', close)
// The client can request a notification for a given transfer id
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MatthewPhinney I'm not ware of us having any documentation for the websocket protocol as of yet. Let me know if you happen to know.

@gip gip force-pushed the ws_notifications branch 3 times, most recently from 1f28f03 to 5d31e6c Compare June 30, 2016 18:47
@@ -481,11 +473,27 @@ function * insertTransfers (externalTransfers) {
converters.convertToInternalTransfer))
}

function * resendNotification (transferId) {
Copy link
Contributor

@MatthewPhinney MatthewPhinney Jun 30, 2016

Choose a reason for hiding this comment

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

I think you want some kind of check here to ensure the party requesting the notification has privileges to view this transfer ... although it doesn't look like the get transfer endpoint has any sort of authentication either.

Copy link
Contributor Author

@gip gip Jun 30, 2016

Choose a reason for hiding this comment

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

Good points, but actually I don't think it's a problem because:

That being said, if a client sends a request with a transfer id which correspond to a transfer that doesn't belong to that account:

  • A notification will be sent to the clients listening for notifications on that account, even though they have not requested a new notification
  • I don't think that is a problem as this is very unlikely to happen. The probability of collision for generated UUIDs is probably lower than the risk of being reincarnated as an olive in a next life

There is an issue with this implementation though. If 2 (or more) clients are listening for notifications for a given account and only one of the client requests a new notification for a given transfer. Then all the clients will receive the notification, not only the requesting one. We could either:

  • Change this behaviour (that would take some work)
  • Add to the specs that notification may be sent more than once. Clients would therefore need to be idempotent

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that makes sense. I think we can expect clients to be robust enough to handle duplicate notifications, should they occur.

@gip gip force-pushed the ws_notifications branch 4 times, most recently from 3d39fd7 to 5d95bf8 Compare July 1, 2016 19:10
@justmoon
Copy link
Contributor

justmoon commented Jul 2, 2016

Agree on taking out the REST hooks. This will significantly improve ledger performance.

Not sure why the resend functionality is being added. Instead of requesting a resend, what's wrong with simply GETting the transfer (and fulfillment if needed.) That seems overall more efficient for the client because they get the transfer in the response instead of getting it separately as a notification, which would mean that they have to reconstruct all the context again such as looking up the transfer from the database etc.

I'm assuming that this design was chosen in order to avoid duplicating the code that currently exists in the websocket notification handler. May I suggest simply refactoring the app such that the notification handler is a reusable function which can be called both from the notification handler and when manually requesting the transfer from the ledger. This will be simpler, more performant and removes the need for the resend feature in the ledger.

@gip
Copy link
Contributor Author

gip commented Jul 5, 2016

The resend notification feature may be better in term if performance and stability for the ledger - doing things asynchronously usually brings better performance in large distributed systems. The ledger would have better control over what it being executed. Plus there would be a unique channel for a client to get notifications.

I don't think this (huge) PR should be delayed by this discussion however. In the interest of speed, I have removed the resend logic for now. I'll do a new PR once we've discussed further and find an agreement. Can you please review @justmoon.

@justmoon
Copy link
Contributor

justmoon commented Jul 7, 2016

LGTM

Improves performance and I'm happy to see this much dead code removed. 👍

@gip gip merged commit 8cfe503 into master Jul 7, 2016
@gip gip deleted the ws_notifications branch July 7, 2016 22:58
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.

5 participants