bluechi icon indicating copy to clipboard operation
bluechi copied to clipboard

Remove node name duplication in the `ListUnits` and `ListUnitFiles` API

Open engelmi opened this issue 7 months ago • 0 comments

Please describe what you would like to see

For the API method ListUnits

the returned structure is a list of all unit (files) and the name of the respective node a(sssssssouso), for example:

[
  ("node-1", ...),
  ("node-1", ...),
  ("node-2", ...),
  ("node-2", ...),
  ...
]

The node name is duplicated quite a lot in this structure. It would be more efficient to use a dict and store it only once, e.g.:

{
  "node-1": [
    (...), (...), ...
  ],
  "node-2": [
    (...), (...), ...
  ],
  ...

This could be achieved by changing the D-Bus API to a{sa(ssssssouso)} - where the dict has the node name as key (basic D-Bus type string) and the unit information as value (container D-Bus type). This way the node name isn't repeated n times for n units.

Notes: * The same applies for ListUnitFiles (added in https://github.com/eclipse-bluechi/bluechi/issues/889) ** This is a breaking API change

engelmi avatar Jul 22 '24 11:07 engelmi