mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Move idempotency token to write options. Remove DispatchIdempotent
This commit is contained in:
@@ -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
|
||||
|
||||
23
api/jobs.go
23
api/jobs.go
@@ -397,22 +397,6 @@ func (j *Jobs) Dispatch(jobID string, meta map[string]string,
|
||||
return &resp, wm, nil
|
||||
}
|
||||
|
||||
func (j *Jobs) DispatchIdempotent(jobID string, meta map[string]string,
|
||||
payload []byte, idempotencyToken string, q *WriteOptions) (*JobDispatchResponse, *WriteMeta, error) {
|
||||
var resp JobDispatchResponse
|
||||
req := &JobDispatchRequest{
|
||||
JobID: jobID,
|
||||
Meta: meta,
|
||||
Payload: payload,
|
||||
IdempotencyToken: idempotencyToken,
|
||||
}
|
||||
wm, err := j.client.write("/v1/job/"+url.PathEscape(jobID)+"/dispatch", req, &resp, q)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return &resp, wm, nil
|
||||
}
|
||||
|
||||
// Revert is used to revert the given job to the passed version. If
|
||||
// enforceVersion is set, the job is only reverted if the current version is at
|
||||
// the passed version.
|
||||
@@ -1278,10 +1262,9 @@ type DesiredUpdates struct {
|
||||
}
|
||||
|
||||
type JobDispatchRequest struct {
|
||||
JobID string
|
||||
Payload []byte
|
||||
Meta map[string]string
|
||||
IdempotencyToken string
|
||||
JobID string
|
||||
Payload []byte
|
||||
Meta map[string]string
|
||||
}
|
||||
|
||||
type JobDispatchResponse struct {
|
||||
|
||||
@@ -385,6 +385,9 @@ type WriteRequest struct {
|
||||
// AuthToken is secret portion of the ACL token used for the request
|
||||
AuthToken string
|
||||
|
||||
// IdempotencyToken can be used to ensure the write is idempotent.
|
||||
IdempotencyToken string
|
||||
|
||||
InternalRpcInfo
|
||||
}
|
||||
|
||||
@@ -728,10 +731,9 @@ type JobScaleStatusRequest struct {
|
||||
|
||||
// JobDispatchRequest is used to dispatch a job based on a parameterized job
|
||||
type JobDispatchRequest struct {
|
||||
JobID string
|
||||
Payload []byte
|
||||
Meta map[string]string
|
||||
IdempotencyToken string
|
||||
JobID string
|
||||
Payload []byte
|
||||
Meta map[string]string
|
||||
WriteRequest
|
||||
}
|
||||
|
||||
|
||||
3
vendor/github.com/hashicorp/nomad/api/api.go
generated
vendored
3
vendor/github.com/hashicorp/nomad/api/api.go
generated
vendored
@@ -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
|
||||
|
||||
23
vendor/github.com/hashicorp/nomad/api/jobs.go
generated
vendored
23
vendor/github.com/hashicorp/nomad/api/jobs.go
generated
vendored
@@ -397,22 +397,6 @@ func (j *Jobs) Dispatch(jobID string, meta map[string]string,
|
||||
return &resp, wm, nil
|
||||
}
|
||||
|
||||
func (j *Jobs) DispatchIdempotent(jobID string, meta map[string]string,
|
||||
payload []byte, idempotencyToken string, q *WriteOptions) (*JobDispatchResponse, *WriteMeta, error) {
|
||||
var resp JobDispatchResponse
|
||||
req := &JobDispatchRequest{
|
||||
JobID: jobID,
|
||||
Meta: meta,
|
||||
Payload: payload,
|
||||
IdempotencyToken: idempotencyToken,
|
||||
}
|
||||
wm, err := j.client.write("/v1/job/"+url.PathEscape(jobID)+"/dispatch", req, &resp, q)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return &resp, wm, nil
|
||||
}
|
||||
|
||||
// Revert is used to revert the given job to the passed version. If
|
||||
// enforceVersion is set, the job is only reverted if the current version is at
|
||||
// the passed version.
|
||||
@@ -1278,10 +1262,9 @@ type DesiredUpdates struct {
|
||||
}
|
||||
|
||||
type JobDispatchRequest struct {
|
||||
JobID string
|
||||
Payload []byte
|
||||
Meta map[string]string
|
||||
IdempotencyToken string
|
||||
JobID string
|
||||
Payload []byte
|
||||
Meta map[string]string
|
||||
}
|
||||
|
||||
type JobDispatchResponse struct {
|
||||
|
||||
Reference in New Issue
Block a user