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 {
|
||||
JobType string `json:"jobType"`
|
||||
MaxJobsToActivate *int32 `json:"maxJobsToActivate"`
|
||||
Timeout metadata.Duration `json:"timeout"`
|
||||
WorkerName string `json:"workerName"`
|
||||
FetchVariables []string `json:"fetchVariables"`
|
||||
RequestTimeout metadata.Duration `json:"requestTimeout"`
|
||||
JobType string `json:"jobType"`
|
||||
MaxJobsToActivate *int32 `json:"maxJobsToActivate"`
|
||||
Timeout *metadata.Duration `json:"timeout,omitempty"`
|
||||
WorkerName string `json:"workerName"`
|
||||
FetchVariables []string `json:"fetchVariables"`
|
||||
RequestTimeout *metadata.Duration `json:"requestTimeout,omitempty"`
|
||||
}
|
||||
|
||||
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).
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ func (z *ZeebeCommand) activateJobs(ctx context.Context, req *bindings.InvokeReq
|
|||
}
|
||||
|
||||
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)
|
||||
defer cancel()
|
||||
response, err = cmd.Send(ctxWithTimeout)
|
||||
|
|
|
@ -148,7 +148,7 @@ func TestActivateJobs(t *testing.T) {
|
|||
payload := activateJobsPayload{
|
||||
JobType: "a",
|
||||
MaxJobsToActivate: new(int32),
|
||||
Timeout: kitmd.Duration{Duration: 1 * time.Second},
|
||||
Timeout: &kitmd.Duration{Duration: 1 * time.Second},
|
||||
WorkerName: "b",
|
||||
FetchVariables: []string{"a", "b", "c"},
|
||||
}
|
||||
|
|
|
@ -32,13 +32,13 @@ var (
|
|||
)
|
||||
|
||||
type createInstancePayload struct {
|
||||
BpmnProcessID string `json:"bpmnProcessId"`
|
||||
ProcessDefinitionKey *int64 `json:"processDefinitionKey"`
|
||||
Version *int32 `json:"version"`
|
||||
Variables interface{} `json:"variables"`
|
||||
WithResult bool `json:"withResult"`
|
||||
FetchVariables []string `json:"fetchVariables"`
|
||||
RequestTimeout metadata.Duration `json:"requestTimeout"`
|
||||
BpmnProcessID string `json:"bpmnProcessId"`
|
||||
ProcessDefinitionKey *int64 `json:"processDefinitionKey"`
|
||||
Version *int32 `json:"version"`
|
||||
Variables interface{} `json:"variables"`
|
||||
WithResult bool `json:"withResult"`
|
||||
FetchVariables []string `json:"fetchVariables"`
|
||||
RequestTimeout *metadata.Duration `json:"requestTimeout,omitempty"`
|
||||
}
|
||||
|
||||
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
|
||||
// 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)
|
||||
defer cancel()
|
||||
response, err = cmd3.WithResult().FetchVariables(payload.FetchVariables...).Send(ctxWithTimeout)
|
||||
|
|
|
@ -29,11 +29,11 @@ import (
|
|||
var ErrMissingRetries = errors.New("retries is a required attribute")
|
||||
|
||||
type failJobPayload struct {
|
||||
JobKey *int64 `json:"jobKey"`
|
||||
Retries *int32 `json:"retries"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
RetryBackOff metadata.Duration `json:"retryBackOff"`
|
||||
Variables interface{} `json:"variables"`
|
||||
JobKey *int64 `json:"jobKey"`
|
||||
Retries *int32 `json:"retries"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
RetryBackOff *metadata.Duration `json:"retryBackOff,omitempty"`
|
||||
Variables interface{} `json:"variables"`
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
if payload.RetryBackOff.Duration != time.Duration(0) {
|
||||
if payload.RetryBackOff != nil && payload.RetryBackOff.Duration != time.Duration(0) {
|
||||
cmd = cmd.RetryBackoff(payload.RetryBackOff.Duration)
|
||||
}
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ import (
|
|||
var ErrMissingMessageName = errors.New("messageName is a required attribute")
|
||||
|
||||
type publishMessagePayload struct {
|
||||
MessageName string `json:"messageName"`
|
||||
CorrelationKey string `json:"correlationKey"`
|
||||
MessageID string `json:"messageId"`
|
||||
TimeToLive metadata.Duration `json:"timeToLive"`
|
||||
Variables interface{} `json:"variables"`
|
||||
MessageName string `json:"messageName"`
|
||||
CorrelationKey string `json:"correlationKey"`
|
||||
MessageID string `json:"messageId"`
|
||||
TimeToLive *metadata.Duration `json:"timeToLive,omitempty"`
|
||||
Variables interface{} `json:"variables"`
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
if payload.TimeToLive.Duration != time.Duration(0) {
|
||||
if payload.TimeToLive != nil && payload.TimeToLive.Duration != time.Duration(0) {
|
||||
cmd = cmd.TimeToLive(payload.TimeToLive.Duration)
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ func TestPublishMessage(t *testing.T) {
|
|||
MessageName: "a",
|
||||
CorrelationKey: "b",
|
||||
MessageID: "c",
|
||||
TimeToLive: kitmd.Duration{Duration: 1 * time.Second},
|
||||
TimeToLive: &kitmd.Duration{Duration: 1 * time.Second},
|
||||
Variables: map[string]interface{}{
|
||||
"key": "value",
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue