Move idempotency token to write options. Remove DispatchIdempotent

This commit is contained in:
Alex Munda
2021-06-30 14:23:37 -05:00
parent d83ff8b8c9
commit 63d8e92e90
5 changed files with 18 additions and 44 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

View File

@@ -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 {

View File

@@ -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
}

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

View File

@@ -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 {