One singular self._delete_task: remove _num_connections and deprecate prune_instances
#5425
+33
−45
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.
Motivation
TL-DR: If you want something to always get cleaned up, clean it up in one place, never switch PICs. Keep logic clean and firm by always cleaning up when the function elapses - only way to stop it is to cancel the function.
So a client should, ideally, self-destruct.
But now a client is destroyed in a variety of places, and only sometimes it actually destroys.
Client.prune_instances_delete_tasks, which can be multiple, but we act on the last one because we only actually delete whenself._num_connections[document_id] == 0This is quite some technical debt (no we are not 🤡 enough to write this on day one). Some left from 2.x when we had auto-index client. This PR seeks to eliminate it.
Implementation
Removals and deprecations:
_num_connections._delete_tasks(plural).Client.prune_instances(does nothing now)Additions
_delete_task. Considering the above, only the last one matter anyways, so why bother.self._reset_self_delete: For share the logic between the existing socket-disconnect self-delete, and the before-connect 60-second self-deleteProgress
Client.prune_instancesthough.