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.
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
Add
connect()
,disconnect()
, deprecatesetAutoReconnect()
,resume()
, andconnected
#9439Add
connect()
,disconnect()
, deprecatesetAutoReconnect()
,resume()
, andconnected
#9439Changes from 6 commits
26fcaf4
1126595
8b2e788
df6192c
879400f
660a70f
b8edf82
a05fe75
11c7cd8
dd1a872
94f1401
5847ea0
1ad1809
a8c083b
c6bbc93
5a58350
b7a4697
05271fb
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Should we add
connect()
anddisconnect()
as optional right away, especially since you're mentioning them here, and to help consumers transition? I don't think adding an optional thing is ever breaking (but could be wrong).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.
I actually had them added as optional earlier but changed it after discussion here. To summarize, I will have to add the functions to
IFluidContainer
in a separate PR anyway, so I am planning to add them toIContainer
andIFluidContainer
in one PR. This way we won't have to make another PR to change it from optional to mandatory functions.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.
Ok. Feel free to ignore what I'm about to say then :)
In general, I believe having a property absent is completely equivalent to having it present but optional, in terms of compatibility. It's just a hint saying "you may find something here...". So I would think you can and should add the optional functions to both interfaces in this PR.
To say the above another way, changing a member from optional to mandatory is equivalent to adding it when it's missing. At least I think so - correct me if I'm wrong, this stuff really bends my brain.
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.
@markfields The main problem with going from optional to mandatory I think is that it can still be a breaking change to anyone with an external implementation of the interface, where an implementation/object matching the interface suddenly no longer does so. It sounds like this shouldn't be an issue in this case though, but if there's a breaking change no matter how you slice it there's some appeal to doing just one step instead of two
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.
I'm saying something different, I agree with that for sure.
Going from nothing to optional is never any trouble. Going from optional to required is trouble - it's as much trouble as adding a required thing outright. So might as well add optional earlier than later to give people an easier time onboarding/preparing.
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.
What's the appeal of doing one step instead of two?
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.
I agree with @heliocliu and I'm not sure why this was removed from this PR? The goal of this PR is to introduce connect and disconnect at the Container level. Since we are enforcing using IContainer we are telling devs to use APIs as part of depreciation that aren't actually exposed.
Seems like the right step is to add them as optional as part of this PR and include the version in the Breaking.md that we will be making the breaking change. Then make them mandatory in next (or whatever breaking change we decide)
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.
Fewer steps 🙃
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.
Please add documentation
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.
These should actually just inherit the docs from the interface.
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.
Let's think about what the reason should be. It used to be different for
resume
v.setAutoReconnect
, now it will be the same.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.
@markfields, thoughts on
DocumentConnect
? This would match theDocumentOpen
reason used when the container is initially created and tries to connect.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.
I'd like to see code reuse with existing resume/setAutoReconnect flow to easier see where this logic is different from existing logic. Ideally there should be no differences and one implementation should call into another, right?
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.
So basically have
connect()
callresumeInteranl()
andsetAutoReconnect(true)
? If so, we should probably makesetAutoReconnect()
a private function (since we would no longer be removing it).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.
It does not matter which way you go (connect calling setAutoReconnect(true) or other way around). We can clean that later when we remove deprecated APIs (and have just one function), but for now it would be really great to see if new functionality differs from the previous one through code reuse. If you can't reuse code, that means it's not 1-to-1 reman, and it should be clearly spelled out for consumers such that they are not caught by surprise.
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.
The reason why I wrote a new
connectInernal()
function is because I felt that what we wanted is an overlap between the currentresume()
andsetAutoReconnect(true)
functions. However, I didn't want to call those functions straight up because there is a bit of overlap between the two. For example, they both call end up callingthis.connectToDeltaStream()
. Although I don't think this would cause issues it did seem a bit messy so I ended up essentially combining the functions while trying to eliminate the overlap (which resulted inconnectInternal()
). So I do believe we could reuse code, but it would be a bit inefficient. Do you think this is a bad approach and we should just reuse the existing logic?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.
So I assume the guidance is for people to move from setAutoReconnect(true) to connect() calls.
The two obvious things I see that are different in flows:
Second one is likely not interesting and can probably be removed (or added).
First part - I do not know, it feels like it should apply here (I'd look at history on when/why it was added)
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 reasonable after latest changes.
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.
I think you could call
resumeInternal
from the top ofconnectInternal
now, would be nice to reduce code duplication (andresumeInternal
looks like it will stick around since it's called fromattach
)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.
And totally optional, but consider pulling the
if (currentMode !== mode) { ... }
block into a helper, since it's now here in triplicate. And it's pretty crucial the three places stay in sync since they're messing with the same state.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.
+1 to putting
manualReconnectInProgress
back the way it was... Or if not, then just delete that variable because this was the only place it was set to true.Probably should take a pass over the values used for
connectionInitiationReason
inlogConnectionStateChangeTelemetry
and see if they still make sense given the merging ofresume
andsetAutoReconnect(true)
from an API standpoint. I think I'm confused why "AutoReconnect" and "ManualReconnect" were distinguished by this case anyway...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.
I agree with your first two comments and will update the PR shortly to make these changes. Re: your last comment, since we merged
resume()
andsetAutoReconnect()
, I think it does make sense to just deletemanualReconnectInProgress
.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.
Please add documentation.
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.
Note that if we are in the process of attempting to connect, then this.connectionState would be disconnected, and calling this API would be noop. But the outcome - connection will succeed eventually, while user clearly does not want that. This is a new flow that did not exist before, thus I think we do not have good mechanisms to control it (i.e. there is no way to cancel pending connection, the only thing we do is to throw away connection on success if container is closed).
I think this needs to be redesigned in some way and implemented correctly (i.e. doing what users expect from this API). It's probably fine to do it as separate PR, but we should do it right after that, as it is not that uncommon situation (especially when user is offline).
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.
If you allow to go past that check and assess this._deltaManager.connectionManager.reconnectMode in disconnectInternal(), then I think it will do 95% of what is required (assuming that DeltaManager can throw this connection away once it connects and it realizes that reconnect mode is Disabled, though I think we need to use Never, not Disabled, and review code around it, as I think some asserts will not like it)
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.
Would you be able to explain why
Never
is preferred overDisabled
? At the moment we seem to only useNever
to indicate that a container should never be able to reconnect in the future. This doesn't seem to align with what we want to accomplish withdisconnect()
, since we want to allow the container to reconnect at a later point when callingconnect()
.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.
I think Disabled is used (for example) for agents (including summarizer) and it allows one connection. So decision not to reconnect is made on loss of connection, not when connection is successfully established. Here, when user wants to stop connectivity flow, it's too late to check (pending connection is already in flight), and once pending connection is established it can't make decision to abandon such connection for Disalbed state (as that will kill agent connection flow). So we need some other state to differentiate "first connection" vs. "connection should not be allows".
I think Never might also be wrong (as some other things are tied to it), so more exploration is required to properly handle that case.
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.
Sounds like it's probably best to look into this (and the other concerns you mentioned above with
disconnect()
during a pending connection) in a separate PR like you suggested.