Skip to content

Commit 48589fc

Browse files
DelayStart param cadence client changes (#1079)
1 parent b1375e6 commit 48589fc

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

idls

Submodule idls updated from ab8788a to 4404cbf

internal/client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ type (
392392
// supported when Cadence server is using ElasticSearch). The key and value type must be registered on Cadence server side.
393393
// Use GetSearchAttributes API to get valid key and corresponding value type.
394394
SearchAttributes map[string]interface{}
395+
396+
// DelayStartSeconds - Seconds to delay the workflow start
397+
// The resolution is seconds.
398+
// Optional: defaulted to 0 seconds
399+
DelayStart time.Duration
395400
}
396401

397402
// RetryPolicy defines the retry policy.

internal/internal_workflow_client.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ import (
2626
"encoding/json"
2727
"errors"
2828
"fmt"
29-
"go.uber.org/cadence/internal/common/serializer"
3029
"reflect"
3130
"time"
3231

32+
"go.uber.org/cadence/internal/common/serializer"
33+
3334
"github.com/opentracing/opentracing-go"
3435
"github.com/pborman/uuid"
3536
"github.com/uber-go/tally"
@@ -188,6 +189,11 @@ func (wc *workflowClient) StartWorkflow(
188189
return nil, err
189190
}
190191

192+
delayStartSeconds := common.Int32Ceil(options.DelayStart.Seconds())
193+
if delayStartSeconds < 0 {
194+
return nil, errors.New("Invalid DelayStart option")
195+
}
196+
191197
// create a workflow start span and attach it to the context object.
192198
// N.B. we need to finish this immediately as jaeger does not give us a way
193199
// to recreate a span given a span context - which means we will run into
@@ -218,6 +224,7 @@ func (wc *workflowClient) StartWorkflow(
218224
Memo: memo,
219225
SearchAttributes: searchAttr,
220226
Header: header,
227+
DelayStartSeconds: common.Int32Ptr(delayStartSeconds),
221228
}
222229

223230
var response *s.StartWorkflowExecutionResponse
@@ -386,6 +393,11 @@ func (wc *workflowClient) SignalWithStartWorkflow(ctx context.Context, workflowI
386393
return nil, err
387394
}
388395

396+
delayStartSeconds := common.Int32Ceil(options.DelayStart.Seconds())
397+
if delayStartSeconds < 0 {
398+
return nil, errors.New("Invalid DelayStart option")
399+
}
400+
389401
// create a workflow start span and attach it to the context object. finish it immediately
390402
ctx, span := createOpenTracingWorkflowSpan(ctx, wc.tracer, time.Now(), fmt.Sprintf("SignalWithStartWorkflow-%s", workflowType.Name), workflowID)
391403
span.Finish()
@@ -411,6 +423,7 @@ func (wc *workflowClient) SignalWithStartWorkflow(ctx context.Context, workflowI
411423
SearchAttributes: searchAttr,
412424
WorkflowIdReusePolicy: options.WorkflowIDReusePolicy.toThriftPtr(),
413425
Header: header,
426+
DelayStartSeconds: common.Int32Ptr(delayStartSeconds),
414427
}
415428

416429
var response *s.StartWorkflowExecutionResponse

0 commit comments

Comments
 (0)