Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
2c1b10d8
Commit
2c1b10d8
authored
May 23, 2019
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added status streaming to Init grpc call
This will be useful in the next commits
parent
02a8800f
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
197 additions
and
123 deletions
+197
-123
cli/cli.go
cli/cli.go
+1
-1
commands/instances.go
commands/instances.go
+1
-1
daemon/client/client.go
daemon/client/client.go
+23
-4
daemon/daemon.go
daemon/daemon.go
+10
-2
rpc/commands.pb.go
rpc/commands.pb.go
+159
-114
rpc/commands.proto
rpc/commands.proto
+3
-1
No files found.
cli/cli.go
View file @
2c1b10d8
...
...
@@ -86,7 +86,7 @@ func packageManagerInitReq() *rpc.InitReq {
func
InitInstance
()
*
rpc
.
InitResp
{
logrus
.
Info
(
"Initializing package manager"
)
req
:=
packageManagerInitReq
()
resp
,
err
:=
commands
.
Init
(
context
.
Background
(),
req
)
resp
,
err
:=
commands
.
Init
(
context
.
Background
(),
req
,
OutputProgressBar
(),
OutputTaskProgress
()
)
if
err
!=
nil
{
formatter
.
PrintError
(
err
,
"Error initializing package manager"
)
os
.
Exit
(
ErrGeneric
)
...
...
commands/instances.go
View file @
2c1b10d8
...
...
@@ -72,7 +72,7 @@ func GetLibraryManager(req InstanceContainer) *librariesmanager.LibrariesManager
return
i
.
lm
}
func
Init
(
ctx
context
.
Context
,
req
*
rpc
.
InitReq
)
(
*
rpc
.
InitResp
,
error
)
{
func
Init
(
ctx
context
.
Context
,
req
*
rpc
.
InitReq
,
downloadCB
DownloadProgressCB
,
taskCB
TaskProgressCB
)
(
*
rpc
.
InitResp
,
error
)
{
inConfig
:=
req
.
GetConfiguration
()
if
inConfig
==
nil
{
return
nil
,
fmt
.
Errorf
(
"invalid request"
)
...
...
daemon/client/client.go
View file @
2c1b10d8
...
...
@@ -46,7 +46,7 @@ func main() {
// INIT
fmt
.
Println
(
"=== calling Init"
)
initResp
,
err
:=
client
.
Init
(
context
.
Background
(),
&
rpc
.
InitReq
{
initResp
Stream
,
err
:=
client
.
Init
(
context
.
Background
(),
&
rpc
.
InitReq
{
Configuration
:
&
rpc
.
Configuration
{
DataDir
:
datadir
,
},
...
...
@@ -55,9 +55,28 @@ func main() {
fmt
.
Printf
(
"Error creating server instance: %s
\n
"
,
err
)
os
.
Exit
(
1
)
}
instance
:=
initResp
.
GetInstance
()
fmt
.
Printf
(
"---> %+v
\n
"
,
initResp
)
fmt
.
Println
()
var
instance
*
rpc
.
Instance
for
{
initResp
,
err
:=
initRespStream
.
Recv
()
if
err
==
io
.
EOF
{
fmt
.
Println
()
break
}
if
err
!=
nil
{
fmt
.
Printf
(
"Init error: %s
\n
"
,
err
)
os
.
Exit
(
1
)
}
if
initResp
.
GetInstance
()
!=
nil
{
instance
=
initResp
.
GetInstance
()
fmt
.
Printf
(
"---> %+v
\n
"
,
initResp
)
}
if
initResp
.
GetDownloadProgress
()
!=
nil
{
fmt
.
Printf
(
">> DOWNLOAD: %s
\n
"
,
initResp
.
GetDownloadProgress
())
}
if
initResp
.
GetTaskProgress
()
!=
nil
{
fmt
.
Printf
(
">> TASK: %s
\n
"
,
initResp
.
GetTaskProgress
())
}
}
// UPDATE-INDEX
fmt
.
Println
(
"=== calling UpdateIndex"
)
...
...
daemon/daemon.go
View file @
2c1b10d8
...
...
@@ -103,8 +103,16 @@ func (s *ArduinoCoreServerImpl) UpdateLibrariesIndex(req *rpc.UpdateLibrariesInd
return
stream
.
Send
(
&
rpc
.
UpdateLibrariesIndexResp
{})
}
func
(
s
*
ArduinoCoreServerImpl
)
Init
(
ctx
context
.
Context
,
req
*
rpc
.
InitReq
)
(
*
rpc
.
InitResp
,
error
)
{
return
commands
.
Init
(
ctx
,
req
)
func
(
s
*
ArduinoCoreServerImpl
)
Init
(
req
*
rpc
.
InitReq
,
stream
rpc
.
ArduinoCore_InitServer
)
error
{
resp
,
err
:=
commands
.
Init
(
stream
.
Context
(),
req
,
func
(
p
*
rpc
.
DownloadProgress
)
{
stream
.
Send
(
&
rpc
.
InitResp
{
DownloadProgress
:
p
})
},
func
(
p
*
rpc
.
TaskProgress
)
{
stream
.
Send
(
&
rpc
.
InitResp
{
TaskProgress
:
p
})
},
)
if
err
!=
nil
{
return
err
}
fmt
.
Println
(
resp
)
return
stream
.
Send
(
resp
)
}
func
(
s
*
ArduinoCoreServerImpl
)
Compile
(
req
*
rpc
.
CompileReq
,
stream
rpc
.
ArduinoCore_CompileServer
)
error
{
...
...
rpc/commands.pb.go
View file @
2c1b10d8
This diff is collapsed.
Click to expand it.
rpc/commands.proto
View file @
2c1b10d8
...
...
@@ -34,7 +34,7 @@ service ArduinoCore {
//-------------------
// Start a new instance of the Arduino Core Service
rpc
Init
(
InitReq
)
returns
(
InitResp
)
{}
rpc
Init
(
InitReq
)
returns
(
stream
InitResp
)
{}
// Destroy an instance of the Arduino Core Service
rpc
Destroy
(
DestroyReq
)
returns
(
DestroyResp
)
{}
...
...
@@ -115,6 +115,8 @@ message InitResp {
Instance
instance
=
1
;
repeated
string
platforms_index_errors
=
2
;
string
libraries_index_error
=
3
;
DownloadProgress
download_progress
=
4
;
TaskProgress
task_progress
=
5
;
}
message
DestroyReq
{
Instance
instance
=
1
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment