Skip to content

Commit 95ab26e

Browse files
committed
Added GRPC feedback on TaskProgress
1 parent 693036c commit 95ab26e

File tree

6 files changed

+118
-90
lines changed

6 files changed

+118
-90
lines changed

daemon/client/client.go

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ func main() {
5555
fmt.Printf("Install error: %s\n", err)
5656
return
5757
}
58-
fmt.Printf("%s\n", installResp.GetProgress())
58+
if installResp.GetProgress() != nil {
59+
fmt.Printf(">> DOWNLOAD: %s\n", installResp.GetProgress())
60+
}
61+
if installResp.GetTaskProgress() != nil {
62+
fmt.Printf(">> TASK: %s\n", installResp.GetTaskProgress())
63+
}
5964
}
6065
fmt.Println("Installation completed!")
6166
}
@@ -81,7 +86,12 @@ func main() {
8186
fmt.Printf("Upgrade error: %s\n", err)
8287
os.Exit(1)
8388
}
84-
fmt.Printf("%s\n", upgradeResp.GetProgress())
89+
if upgradeResp.GetProgress() != nil {
90+
fmt.Printf(">> DOWNLOAD: %s\n", upgradeResp.GetProgress())
91+
}
92+
if upgradeResp.GetTaskProgress() != nil {
93+
fmt.Printf(">> TASK: %s\n", upgradeResp.GetTaskProgress())
94+
}
8595
}
8696
fmt.Println("Upgrade completed!")
8797

@@ -114,25 +124,13 @@ func main() {
114124
fmt.Printf("Compile error: %s\n", err)
115125
os.Exit(1)
116126
}
117-
fmt.Printf("%s", compResp.GetOutput())
118-
}
119-
/*
120-
compile, err := client.Compile(context.Background(), &pb.CompileReq{})
121-
if err != nil {
122-
log.Fatal(err)
127+
if compResp.GetOutput() != nil {
128+
fmt.Printf("%s", compResp.GetOutput())
123129
}
124-
for {
125-
resp, err := compile.Recv()
126-
if err == io.EOF {
127-
break
128-
}
129-
if err != nil {
130-
fmt.Printf("%+v\n", err)
131-
log.Fatal(err)
132-
}
133-
fmt.Println(resp)
130+
if compResp.GetTaskProgress() != nil {
131+
fmt.Printf(">> TASK: %s\n", compResp.GetTaskProgress())
134132
}
135-
*/
133+
}
136134

137135
_, err = client.PlatformUninstall(context.Background(), &rpc.PlatformUninstallReq{
138136
Instance: instance,

daemon/daemon.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (s *ArduinoCoreServerImpl) Compile(req *rpc.CompileReq, stream rpc.ArduinoC
6868
}
6969
}()
7070
resp, err := compile.Compile(stream.Context(), req, w, func(taskProgress *rpc.TaskProgress) {
71-
// TODO
71+
stream.Send(&rpc.CompileResp{TaskProgress: taskProgress})
7272
})
7373
stream.Send(resp)
7474
return err
@@ -78,7 +78,7 @@ func (s *ArduinoCoreServerImpl) PlatformInstall(req *rpc.PlatformInstallReq, str
7878
resp, err := core.PlatformInstall(stream.Context(), req, func(progress *rpc.DownloadProgress) {
7979
stream.Send(&rpc.PlatformInstallResp{Progress: progress})
8080
}, func(taskProgress *rpc.TaskProgress) {
81-
// TODO
81+
stream.Send(&rpc.PlatformInstallResp{TaskProgress: taskProgress})
8282
})
8383
if err != nil {
8484
return err
@@ -104,7 +104,7 @@ func (s *ArduinoCoreServerImpl) PlatformUpgrade(req *rpc.PlatformUpgradeReq, str
104104
resp, err := core.PlatformUpgrade(stream.Context(), req, func(progress *rpc.DownloadProgress) {
105105
stream.Send(&rpc.PlatformUpgradeResp{Progress: progress})
106106
}, func(taskProgress *rpc.TaskProgress) {
107-
// TODO
107+
stream.Send(&rpc.PlatformUpgradeResp{TaskProgress: taskProgress})
108108
})
109109
if err != nil {
110110
return err

rpc/compile.pb.go

Lines changed: 41 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpc/compile.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ message CompileReq {
2424

2525
message CompileResp {
2626
bytes output = 1;
27+
TaskProgress task_progress = 2;
2728
}

0 commit comments

Comments
 (0)