rabbah commented on a change in pull request #119: Ack and versioning [work in
progress]
URL:
https://github.com/apache/openwhisk-runtime-go/pull/119#discussion_r370103109
##########
File path: openwhisk/executor.go
##########
@@ -108,15 +115,53 @@ func (proc *Executor) Start() error {
return fmt.Errorf("command exited")
}
Debug("pid: %d", proc.cmd.Process.Pid)
+
go func() {
proc.cmd.Wait()
proc.exited <- true
}()
+
+ // not waiting for an ack, so use a timeout
+ if !waitForAck {
+ select {
+ case <-proc.exited:
+ return fmt.Errorf("command exited")
+ case <-time.After(DefaultTimeoutStart):
+ return nil
+ }
+ return nil
+ }
+
+ // wait for acknowledgement
+ Debug("waiting for an ack")
+ ack := make(chan error)
+ go func() {
+ out, err := proc.output.ReadBytes('\n')
+ if err != nil {
+ ack <- err
+ return
+ }
+ // parse ack
+ var ackData ActionAck
+ err = json.Unmarshal(out, &ackData)
+ if err != nil {
+ ack <- err
+ return
+ }
+ // check ack
+ if !ackData.Ok {
+ ack <- fmt.Errorf("the action did not return a proper
acknowledgement")
Review comment:
as a future todo please lift all the error messages that will be user
visible to a single place so we can edit and polish them for consistency.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services