Minimize expensive API calls #245
Open
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.
The PR is intended to improve performance and minimize expensive API calls.
Docker API has two methods:
ContainersList()
and more detailedInspect()
.The ContainersList() has almost all needed fields except of ENV variables that are shown only in Inspect() response.
So the basic idea of the PR is: what if we'll try to get all fields from ContainersList() but when user opens Single View additionally make Inspect() call to get ENV variables. This also allows us to fetch here other things e.g. #226
Currently ctop works like:
name
, registers a container and calls a separate Inspect() or each container to get all other fields.created
event and callsInspect()
to retrieve all fields and only then registers a container.But in fact the only one container field shown in main view is container's name. All other fields are shown only in Single view.
And the
created
event already contains container's name and image. So we can just register a container directly from event.But in future ctop may receive a new functionality to show other fields directly in main view (e.g. show
image
column). So let's keep the fetching of full info but use cheap ContainersList().Also the PR has additional improvements: Refresh periodically each 5 minutes to remove non existing containers and bulk refresh.