DB: make loading container states optional

Loading container states speed things up when listing all containers but
it comes with a price tag for many other call paths.  Hence, make
loading the state conditional to allow for keeping `podman ps` fast
without other commands regressing in performance.

[NO NEW TESTS NEEDED]

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2023-01-26 10:20:38 +01:00
parent 6132c4d548
commit c74bdae351
13 changed files with 83 additions and 71 deletions

View File

@ -96,9 +96,10 @@ type State interface { //nolint:interfacebloat
// The container being checked must be part of the set namespace.
ContainerInUse(ctr *Container) ([]string, error)
// Retrieves all containers presently in state.
// If `loadState` is set, the containers' state will be loaded as well.
// If a namespace is set, only containers within the namespace will be
// returned.
AllContainers() ([]*Container, error)
AllContainers(loadState bool) ([]*Container, error)
// Get networks the container is currently connected to.
GetNetworks(ctr *Container) (map[string]types.PerNetworkOptions, error)