contribsys / faktory_worker_go

Faktory workers for Go
Mozilla Public License 2.0
242 stars 43 forks source link

All worker are assigned the same wid #12

Closed hassansin closed 6 years ago

hassansin commented 6 years ago

Hello again, When running multiple workers in different docker containers, they all end up having the same worker id. And it confuses the faktory server thinking there is only one worker.

https://github.com/contribsys/faktory_worker_go/blob/master/runner.go#L106 rand.Int63() by default always uses the same seed value of 1. So it returns the same deterministic values when invoked repeatedly. I think it should use an unique id generator instead of a random number for worker id.

hassansin commented 6 years ago

Or if it's important to use random numbers as wid (IDK much about underlying arch), we could use https://golang.org/pkg/crypto/rand/#Read since it has the same behaviour of Ruby's securerandom.hex() method used in the Ruby worker library.