-
Notifications
You must be signed in to change notification settings - Fork 56
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
Support optional multiple recovery scopes #1762
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that scope
is not perfect. To me, it implies that two clients can share the same scope
, which is incorrect. What do you think about name
? name
should be given and unique, for example, recoveryKeyName
.
Also, what do you think about making this feature more general-purpose? For example, clientName
or something similar. We can reuse it for other purposes, such as labeling logs. We've received complaints before that if you use more than one client, it's impossible to work with logs.
Lastly, who will be responsible for adding this to the specification?
Maybe. At this point the words "recovery key" have started to glaze over for me so I've made a poll in
Features that are specific to ably-js, like sessionstorage persistence on beforeunload, or jsonp, or the comet transport don't typically get added to the spec. (the spec is to ensure consistency of implementations, we've generally taken the view that it's not needed if there's only one implementation)
That is indeed a bug, but the bug is that the logger is global. So we can't add anything a client name to each logger instance, because there are no separate logger instances. Once that bug is fixed, I'm not sure a clientName would be particularly needed -- if we want to add a unique string to each log we can use the connectionId, which has the advantage that it doesn't require any customer action and we can correlate with serverside logs. Or if someone wants something fancier they can pass in a logHandler. In particular I think we should have a bias against adding new spec'd client options (i.e. options that we want to add to the spec and all sdks) unless we're sure they're justified. They add lots of work for us (getting every sdk into compliance), and that bit more complexity to the customer for someone scanning down a list of options (not to mention the potential for confusion -- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, would like to re-review once the naming is settled.
New client option where, if specified, the SDK's recovery key will be persisted under that identifier (in sessionstorage), so only another library instance which specifies the same recoveryScope will attempt to recover from it. This is useful if you have multiple ably-js instances sharing a given origin (the origin being the scope of sessionstorage), as otherwise the multiple instances will overwrite each other's recovery keys, and after a reload they will all try and recover the same connection, which is not permitted and will cause broken behaviour. renamed recoveryScope to recoveryKeyStorageName
c8f0ddb
to
34bb6a6
Compare
based on the poll results I've gone with |
@ttypic poke |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
New
recoveryScope
client option where, if specified, the SDK's recovery key will be persisted under that identifier (in sessionstorage), so only another library instance which specifies the same recoveryScope will attempt to recover from it. This is useful if you have multiple ably-js instances sharing a given origin (the origin being the scope of sessionstorage), as otherwise the multiple instances will overwrite each other's recovery keys, and after a reload they will all try and recover the same connection, which is not permitted and will cause broken behaviour.Not entirely happy with
recoveryScope
but I can't think of anything better (considered: recoveryKeyKey, recoveryKeyIdentifier, recoveryDiscriminator, recoveryTag, recoveryMarker, ...)