|
@@ -162,12 +162,9 @@ func (s *FlowSession) Document(c *websocket.Conn) error {
|
|
func (s *FlowSession) NodeRun(c *websocket.Conn, data []byte) error {
|
|
func (s *FlowSession) NodeRun(c *websocket.Conn, data []byte) error {
|
|
var err error
|
|
var err error
|
|
ID := string(data[1 : len(data)-1]) // remove " instead of unmarshalling json
|
|
ID := string(data[1 : len(data)-1]) // remove " instead of unmarshalling json
|
|
- log.Println("Node will run", ID)
|
|
|
|
if s.flow != nil {
|
|
if s.flow != nil {
|
|
- log.Println("Node already running")
|
|
|
|
return errors.New("node already running")
|
|
return errors.New("node already running")
|
|
}
|
|
}
|
|
- log.Println("Flow--\n", s.flow)
|
|
|
|
|
|
|
|
// Clear activity
|
|
// Clear activity
|
|
s.nodeActivity = map[string]*NodeActivity{}
|
|
s.nodeActivity = map[string]*NodeActivity{}
|
|
@@ -182,12 +179,8 @@ func (s *FlowSession) NodeRun(c *websocket.Conn, data []byte) error {
|
|
defer func() { // After routing gone
|
|
defer func() { // After routing gone
|
|
s.flow = nil
|
|
s.flow = nil
|
|
}()
|
|
}()
|
|
- log.Println("Attaching hooks")
|
|
|
|
- //XXX: Transform this function to a typed hook structure
|
|
|
|
-
|
|
|
|
s.flow.Hook(flow.Hook{
|
|
s.flow.Hook(flow.Hook{
|
|
Any: func(name string, ID string, extra ...flow.Data) {
|
|
Any: func(name string, ID string, extra ...flow.Data) {
|
|
- log.Println("Flow lock")
|
|
|
|
s.Lock()
|
|
s.Lock()
|
|
defer s.Unlock()
|
|
defer s.Unlock()
|
|
|
|
|
|
@@ -197,7 +190,6 @@ func (s *FlowSession) NodeRun(c *websocket.Conn, data []byte) error {
|
|
s.nodeActivity[ID] = act
|
|
s.nodeActivity[ID] = act
|
|
}
|
|
}
|
|
status := ""
|
|
status := ""
|
|
- log.Println("Switching funcs:", name)
|
|
|
|
switch name {
|
|
switch name {
|
|
case "Wait":
|
|
case "Wait":
|
|
status = "waiting"
|
|
status = "waiting"
|
|
@@ -214,24 +206,19 @@ func (s *FlowSession) NodeRun(c *websocket.Conn, data []byte) error {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
act.Status = status
|
|
act.Status = status
|
|
- log.Println("Broadcasting the message")
|
|
|
|
s.broadcast(nil, flowmsg.SendMessage{OP: "nodeActivity", Data: s.nodeActivity})
|
|
s.broadcast(nil, flowmsg.SendMessage{OP: "nodeActivity", Data: s.nodeActivity})
|
|
|
|
|
|
},
|
|
},
|
|
})
|
|
})
|
|
|
|
|
|
- log.Println("Fetching operation:", ID)
|
|
|
|
op := s.flow.Res(ID)
|
|
op := s.flow.Res(ID)
|
|
if s.flow.Err() != nil {
|
|
if s.flow.Err() != nil {
|
|
log.Println("error fetching document", s.flow.Err())
|
|
log.Println("error fetching document", s.flow.Err())
|
|
}
|
|
}
|
|
-
|
|
|
|
- log.Println("Execute node", op)
|
|
|
|
- res := op.Process()
|
|
|
|
|
|
+ op.Process()
|
|
if s.flow.Err() != nil {
|
|
if s.flow.Err() != nil {
|
|
log.Println("error processing node", s.flow.Err())
|
|
log.Println("error processing node", s.flow.Err())
|
|
}
|
|
}
|
|
- log.Println("Node Result:", res)
|
|
|
|
}()
|
|
}()
|
|
|
|
|
|
return nil
|
|
return nil
|