fix(zeebe): update to fix bug tests found (#3897)
Signed-off-by: Samantha Coyle <sam@diagrid.io>
This commit is contained in:
parent
c173b024c5
commit
0ab52f7994
|
@ -32,12 +32,12 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type activateJobsPayload struct {
|
type activateJobsPayload struct {
|
||||||
JobType string `json:"jobType"`
|
JobType string `json:"jobType"`
|
||||||
MaxJobsToActivate *int32 `json:"maxJobsToActivate"`
|
MaxJobsToActivate *int32 `json:"maxJobsToActivate"`
|
||||||
Timeout metadata.Duration `json:"timeout"`
|
Timeout *metadata.Duration `json:"timeout,omitempty"`
|
||||||
WorkerName string `json:"workerName"`
|
WorkerName string `json:"workerName"`
|
||||||
FetchVariables []string `json:"fetchVariables"`
|
FetchVariables []string `json:"fetchVariables"`
|
||||||
RequestTimeout metadata.Duration `json:"requestTimeout"`
|
RequestTimeout *metadata.Duration `json:"requestTimeout,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *ZeebeCommand) activateJobs(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
|
func (z *ZeebeCommand) activateJobs(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
|
||||||
|
@ -59,7 +59,7 @@ func (z *ZeebeCommand) activateJobs(ctx context.Context, req *bindings.InvokeReq
|
||||||
JobType(payload.JobType).
|
JobType(payload.JobType).
|
||||||
MaxJobsToActivate(*payload.MaxJobsToActivate)
|
MaxJobsToActivate(*payload.MaxJobsToActivate)
|
||||||
|
|
||||||
if payload.Timeout.Duration != time.Duration(0) {
|
if payload.Timeout != nil && payload.Timeout.Duration != time.Duration(0) {
|
||||||
cmd = cmd.Timeout(payload.Timeout.Duration)
|
cmd = cmd.Timeout(payload.Timeout.Duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ func (z *ZeebeCommand) activateJobs(ctx context.Context, req *bindings.InvokeReq
|
||||||
}
|
}
|
||||||
|
|
||||||
var response []entities.Job
|
var response []entities.Job
|
||||||
if payload.RequestTimeout.Duration != time.Duration(0) {
|
if payload.RequestTimeout != nil && payload.RequestTimeout.Duration != time.Duration(0) {
|
||||||
ctxWithTimeout, cancel := context.WithTimeout(ctx, payload.RequestTimeout.Duration)
|
ctxWithTimeout, cancel := context.WithTimeout(ctx, payload.RequestTimeout.Duration)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
response, err = cmd.Send(ctxWithTimeout)
|
response, err = cmd.Send(ctxWithTimeout)
|
||||||
|
|
|
@ -148,7 +148,7 @@ func TestActivateJobs(t *testing.T) {
|
||||||
payload := activateJobsPayload{
|
payload := activateJobsPayload{
|
||||||
JobType: "a",
|
JobType: "a",
|
||||||
MaxJobsToActivate: new(int32),
|
MaxJobsToActivate: new(int32),
|
||||||
Timeout: kitmd.Duration{Duration: 1 * time.Second},
|
Timeout: &kitmd.Duration{Duration: 1 * time.Second},
|
||||||
WorkerName: "b",
|
WorkerName: "b",
|
||||||
FetchVariables: []string{"a", "b", "c"},
|
FetchVariables: []string{"a", "b", "c"},
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,13 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type createInstancePayload struct {
|
type createInstancePayload struct {
|
||||||
BpmnProcessID string `json:"bpmnProcessId"`
|
BpmnProcessID string `json:"bpmnProcessId"`
|
||||||
ProcessDefinitionKey *int64 `json:"processDefinitionKey"`
|
ProcessDefinitionKey *int64 `json:"processDefinitionKey"`
|
||||||
Version *int32 `json:"version"`
|
Version *int32 `json:"version"`
|
||||||
Variables interface{} `json:"variables"`
|
Variables interface{} `json:"variables"`
|
||||||
WithResult bool `json:"withResult"`
|
WithResult bool `json:"withResult"`
|
||||||
FetchVariables []string `json:"fetchVariables"`
|
FetchVariables []string `json:"fetchVariables"`
|
||||||
RequestTimeout metadata.Duration `json:"requestTimeout"`
|
RequestTimeout *metadata.Duration `json:"requestTimeout,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *ZeebeCommand) createInstance(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
|
func (z *ZeebeCommand) createInstance(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
|
||||||
|
@ -87,7 +87,7 @@ func (z *ZeebeCommand) createInstance(ctx context.Context, req *bindings.InvokeR
|
||||||
//
|
//
|
||||||
// From a code perspective, there are two Send methods in the Zeebe client. One if WithResult was used and
|
// From a code perspective, there are two Send methods in the Zeebe client. One if WithResult was used and
|
||||||
// which extracts the request timeout from the context and another one which will not use any timeout.
|
// which extracts the request timeout from the context and another one which will not use any timeout.
|
||||||
if payload.WithResult && payload.RequestTimeout.Duration != time.Duration(0) {
|
if payload.WithResult && payload.RequestTimeout != nil && payload.RequestTimeout.Duration != time.Duration(0) {
|
||||||
ctxWithTimeout, cancel := context.WithTimeout(ctx, payload.RequestTimeout.Duration)
|
ctxWithTimeout, cancel := context.WithTimeout(ctx, payload.RequestTimeout.Duration)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
response, err = cmd3.WithResult().FetchVariables(payload.FetchVariables...).Send(ctxWithTimeout)
|
response, err = cmd3.WithResult().FetchVariables(payload.FetchVariables...).Send(ctxWithTimeout)
|
||||||
|
|
|
@ -29,11 +29,11 @@ import (
|
||||||
var ErrMissingRetries = errors.New("retries is a required attribute")
|
var ErrMissingRetries = errors.New("retries is a required attribute")
|
||||||
|
|
||||||
type failJobPayload struct {
|
type failJobPayload struct {
|
||||||
JobKey *int64 `json:"jobKey"`
|
JobKey *int64 `json:"jobKey"`
|
||||||
Retries *int32 `json:"retries"`
|
Retries *int32 `json:"retries"`
|
||||||
ErrorMessage string `json:"errorMessage"`
|
ErrorMessage string `json:"errorMessage"`
|
||||||
RetryBackOff metadata.Duration `json:"retryBackOff"`
|
RetryBackOff *metadata.Duration `json:"retryBackOff,omitempty"`
|
||||||
Variables interface{} `json:"variables"`
|
Variables interface{} `json:"variables"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *ZeebeCommand) failJob(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
|
func (z *ZeebeCommand) failJob(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
|
||||||
|
@ -59,7 +59,7 @@ func (z *ZeebeCommand) failJob(ctx context.Context, req *bindings.InvokeRequest)
|
||||||
cmd = cmd.ErrorMessage(payload.ErrorMessage)
|
cmd = cmd.ErrorMessage(payload.ErrorMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
if payload.RetryBackOff.Duration != time.Duration(0) {
|
if payload.RetryBackOff != nil && payload.RetryBackOff.Duration != time.Duration(0) {
|
||||||
cmd = cmd.RetryBackoff(payload.RetryBackOff.Duration)
|
cmd = cmd.RetryBackoff(payload.RetryBackOff.Duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,11 @@ import (
|
||||||
var ErrMissingMessageName = errors.New("messageName is a required attribute")
|
var ErrMissingMessageName = errors.New("messageName is a required attribute")
|
||||||
|
|
||||||
type publishMessagePayload struct {
|
type publishMessagePayload struct {
|
||||||
MessageName string `json:"messageName"`
|
MessageName string `json:"messageName"`
|
||||||
CorrelationKey string `json:"correlationKey"`
|
CorrelationKey string `json:"correlationKey"`
|
||||||
MessageID string `json:"messageId"`
|
MessageID string `json:"messageId"`
|
||||||
TimeToLive metadata.Duration `json:"timeToLive"`
|
TimeToLive *metadata.Duration `json:"timeToLive,omitempty"`
|
||||||
Variables interface{} `json:"variables"`
|
Variables interface{} `json:"variables"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *ZeebeCommand) publishMessage(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
|
func (z *ZeebeCommand) publishMessage(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
|
||||||
|
@ -53,7 +53,7 @@ func (z *ZeebeCommand) publishMessage(ctx context.Context, req *bindings.InvokeR
|
||||||
cmd = cmd.MessageId(payload.MessageID)
|
cmd = cmd.MessageId(payload.MessageID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if payload.TimeToLive.Duration != time.Duration(0) {
|
if payload.TimeToLive != nil && payload.TimeToLive.Duration != time.Duration(0) {
|
||||||
cmd = cmd.TimeToLive(payload.TimeToLive.Duration)
|
cmd = cmd.TimeToLive(payload.TimeToLive.Duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ func TestPublishMessage(t *testing.T) {
|
||||||
MessageName: "a",
|
MessageName: "a",
|
||||||
CorrelationKey: "b",
|
CorrelationKey: "b",
|
||||||
MessageID: "c",
|
MessageID: "c",
|
||||||
TimeToLive: kitmd.Duration{Duration: 1 * time.Second},
|
TimeToLive: &kitmd.Duration{Duration: 1 * time.Second},
|
||||||
Variables: map[string]interface{}{
|
Variables: map[string]interface{}{
|
||||||
"key": "value",
|
"key": "value",
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue