consul-terraform-sync
consul-terraform-sync copied to clipboard
Support parallel task creation
Description
The create task API can accept multiple requests in parallel, but can only create one task at a time. An improvement would be to support the task creation in parallel.
The parallel solution must also take into account potential race conditions when there are multiple requests that use the same task name.
Additional context
The calls will block/wait because there is a lock on the create task handler. This was an intentional choice to simplify the workflow for the initial release of the create task API.
https://github.com/hashicorp/consul-terraform-sync/blob/a67da4f06c1d5ba95f217374272059d4ea11a66b/api/task_create.go#L15-L16