Skip to content

Commit 0305e5e

Browse files
committed
Refactored gRPC UploadUsingProgrammerResponse and BurnBootloaderResponse
1 parent 3cbbc83 commit 0305e5e

File tree

4 files changed

+230
-98
lines changed

4 files changed

+230
-98
lines changed

Diff for: commands/daemon/daemon.go

+28-4
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,20 @@ func (s *ArduinoCoreServerImpl) Upload(req *rpc.UploadRequest, stream rpc.Arduin
302302
// UploadUsingProgrammer FIXMEDOC
303303
func (s *ArduinoCoreServerImpl) UploadUsingProgrammer(req *rpc.UploadUsingProgrammerRequest, stream rpc.ArduinoCoreService_UploadUsingProgrammerServer) error {
304304
syncSend := NewSynchronizedSend(stream.Send)
305-
outStream := feedStreamTo(func(data []byte) { syncSend.Send(&rpc.UploadUsingProgrammerResponse{OutStream: data}) })
306-
errStream := feedStreamTo(func(data []byte) { syncSend.Send(&rpc.UploadUsingProgrammerResponse{ErrStream: data}) })
305+
outStream := feedStreamTo(func(data []byte) {
306+
syncSend.Send(&rpc.UploadUsingProgrammerResponse{
307+
Message: &rpc.UploadUsingProgrammerResponse_OutStream{
308+
OutStream: data,
309+
},
310+
})
311+
})
312+
errStream := feedStreamTo(func(data []byte) {
313+
syncSend.Send(&rpc.UploadUsingProgrammerResponse{
314+
Message: &rpc.UploadUsingProgrammerResponse_ErrStream{
315+
ErrStream: data,
316+
},
317+
})
318+
})
307319
err := upload.UsingProgrammer(stream.Context(), req, outStream, errStream)
308320
outStream.Close()
309321
errStream.Close()
@@ -322,8 +334,20 @@ func (s *ArduinoCoreServerImpl) SupportedUserFields(ctx context.Context, req *rp
322334
// BurnBootloader FIXMEDOC
323335
func (s *ArduinoCoreServerImpl) BurnBootloader(req *rpc.BurnBootloaderRequest, stream rpc.ArduinoCoreService_BurnBootloaderServer) error {
324336
syncSend := NewSynchronizedSend(stream.Send)
325-
outStream := feedStreamTo(func(data []byte) { syncSend.Send(&rpc.BurnBootloaderResponse{OutStream: data}) })
326-
errStream := feedStreamTo(func(data []byte) { syncSend.Send(&rpc.BurnBootloaderResponse{ErrStream: data}) })
337+
outStream := feedStreamTo(func(data []byte) {
338+
syncSend.Send(&rpc.BurnBootloaderResponse{
339+
Message: &rpc.BurnBootloaderResponse_OutStream{
340+
OutStream: data,
341+
},
342+
})
343+
})
344+
errStream := feedStreamTo(func(data []byte) {
345+
syncSend.Send(&rpc.BurnBootloaderResponse{
346+
Message: &rpc.BurnBootloaderResponse_ErrStream{
347+
ErrStream: data,
348+
},
349+
})
350+
})
327351
resp, err := upload.BurnBootloader(stream.Context(), req, outStream, errStream)
328352
outStream.Close()
329353
errStream.Close()

Diff for: docs/UPGRADING.md

+42
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,48 @@ message BuilderResult {
140140

141141
with a clear distinction on which fields are streamed.
142142

143+
### The gRPC response `cc.arduino.cli.commands.v1.UploadUsingProgrammerResponse` and `cc.arduino.cli.commands.v1.BurnBootloaderResponse` has been changed.
144+
145+
The old messages:
146+
147+
```protoc
148+
message UploadUsingProgrammerResponse {
149+
// The output of the upload process.
150+
bytes out_stream = 1;
151+
// The error output of the upload process.
152+
bytes err_stream = 2;
153+
}
154+
155+
message BurnBootloaderResponse {
156+
// The output of the burn bootloader process.
157+
bytes out_stream = 1;
158+
// The error output of the burn bootloader process.
159+
bytes err_stream = 2;
160+
}
161+
```
162+
163+
now have the `oneof` clause that makes explicit the streaming nature of the response:
164+
165+
```protoc
166+
message UploadUsingProgrammerResponse {
167+
oneof message {
168+
// The output of the upload process.
169+
bytes out_stream = 1;
170+
// The error output of the upload process.
171+
bytes err_stream = 2;
172+
}
173+
}
174+
175+
message BurnBootloaderResponse {
176+
oneof message {
177+
// The output of the burn bootloader process.
178+
bytes out_stream = 1;
179+
// The error output of the burn bootloader process.
180+
bytes err_stream = 2;
181+
}
182+
}
183+
```
184+
143185
### The gRPC `cc.arduino.cli.commands.v1.PlatformRelease` has been changed.
144186

145187
We've added a new field called `compatible`. This field indicates if the current platform release is installable or not.

0 commit comments

Comments
 (0)