Merge pull request #10806 from hashicorp/munda/idempotent-job-dispatch

Enforce idempotency of dispatched jobs using token on dispatch request
This commit is contained in:
Mahmood Ali
2021-07-08 10:23:31 -04:00
committed by GitHub
9 changed files with 159 additions and 16 deletions

View File

@@ -93,6 +93,9 @@ type WriteOptions struct {
// ctx is an optional context pass through to the underlying HTTP
// request layer. Use Context() and WithContext() to manage this.
ctx context.Context
// IdempotencyToken can be used to ensure the write is idempotent.
IdempotencyToken string
}
// QueryMeta is used to return meta data about a query
@@ -593,6 +596,9 @@ func (r *request) setWriteOptions(q *WriteOptions) {
if q.AuthToken != "" {
r.token = q.AuthToken
}
if q.IdempotencyToken != "" {
r.params.Set("idempotency_token", q.IdempotencyToken)
}
r.ctx = q.Context()
}