fix: http workers pass their own id #200
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
FIRST COMMIT
Currently, stats are written to the store by the Queue class, and before a Queue instance contains a UUID used to identify the worker.
When a Postgres or Redis Queue is created inside a worker, the ID will be unique to that worker, and the stats are stored as expected. In this case, a Queue instance is created with a unique ID wrapped in a Worker class, which then pushes the stats to the store with the ID from that queue instance, which is unique to that worker.
This is currently not quite the case with HTTP. In an HTTP Proxy scenario, the proxy creates a Queue instance that contains a unique ID for the worker, as is done in the case of Redis and Postgres. When an HTTP worker Queue is created, this instance will contain the unique ID representative of that worker. When, however, the HTTP worker reports its stats, these, rather than being associated with the ID associated with the worker, are related to the ID of the queue instance in the proxy server.
This allows the stats to be attributed to the worker id rather than the id in the proxy.
SECOND COMMIT
In the second commit, I corrected what I think is a semantic error: a queue should not have a worker_id, currently stored under
uuid
in a Queue instance. The second commit removes this id and puts it inside a Worker instance.