// sendResults builds a message body and send the command results back to the scheduler func sendResults(ctx Context, result mig.Command) (err error) { defer func() { if e := recover(); e != nil { err = fmt.Errorf("sendResults() -> %v", e) } ctx.Channels.Log <- mig.Log{CommandID: result.ID, ActionID: result.Action.ID, Desc: "leaving sendResults()"}.Debug() }() ctx.Channels.Log <- mig.Log{CommandID: result.ID, ActionID: result.Action.ID, Desc: "sending command results"} result.AgentQueueLoc = ctx.Agent.QueueLoc body, err := json.Marshal(result) if err != nil { panic(err) } routingKey := fmt.Sprintf("mig.sched.%s", ctx.Agent.QueueLoc) err = publish(ctx, "mig", routingKey, body) if err != nil { panic(err) } return }