diff options
Diffstat (limited to 'worker')
-rw-r--r-- | worker/types/worker.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/worker/types/worker.go b/worker/types/worker.go index e2af61f..5647ae3 100644 --- a/worker/types/worker.go +++ b/worker/types/worker.go @@ -30,11 +30,13 @@ func NewWorker(logger *log.Logger) *Worker { } } -func (worker *Worker) setCallback(msg WorkerMessage, - cb func(msg WorkerMessage)) { - +func (worker *Worker) setId(msg WorkerMessage) { msg.setId(nextId) nextId++ +} + +func (worker *Worker) setCallback(msg WorkerMessage, + cb func(msg WorkerMessage)) { if cb != nil { worker.mutex.Lock() @@ -59,6 +61,8 @@ func (worker *Worker) getCallback(msg WorkerMessage) (func(msg WorkerMessage), func (worker *Worker) PostAction(msg WorkerMessage, cb func(msg WorkerMessage)) { + worker.setId(msg) + if resp := msg.InResponseTo(); resp != nil { worker.Logger.Printf("(ui)=> %T:%T\n", msg, resp) } else { @@ -72,6 +76,8 @@ func (worker *Worker) PostAction(msg WorkerMessage, func (worker *Worker) PostMessage(msg WorkerMessage, cb func(msg WorkerMessage)) { + worker.setId(msg) + if resp := msg.InResponseTo(); resp != nil { worker.Logger.Printf("->(ui) %T:%T\n", msg, resp) } else { |