arduino / arduino-cli

Arduino command line tool
https://arduino.github.io/arduino-cli/latest/
GNU General Public License v3.0
4.24k stars 370 forks source link

gRPC: Use `oneof` clause where appropriate #2593

Closed cmaglie closed 1 month ago

cmaglie commented 2 months ago

Describe the request

Some gRPC calls would benefit from the oneof clause, particularly all the streaming responses.

For example the PlatformInstallResponse, is currently defined as:

message PlatformInstallResponse {
  // Progress of the downloads of the platform and tool files.
  DownloadProgress progress = 1;
  // Description of the current stage of the installation.
  TaskProgress task_progress = 2;
}

could be rewritten as:

message PlatformInstallResponse {
  oneof message {
    // Progress of the downloads of the platform and tool files.
    DownloadProgress progress = 1;
    // Description of the current stage of the installation.
    TaskProgress task_progress = 2;
    // The install result.
    PlatformInstallResult result = 3;
  }
}

message PlatformInstallResult {}

making explicit the exclusive nature of the fields and reserving space for an explicit call result that could be expanded in the future.

Describe the current behavior

N/A

Arduino CLI version

nightly

Operating system

N/A

Operating system version

N/A

Additional context

Some of the gRPC calls have already been changed in a similar way, this request is to propagate the same change in all the API.

Issue checklist