@@ -137,15 +137,19 @@ func (wc *workflowClient) StartWorkflow(
137137
138138// SignalWorkflow signals a workflow in execution.
139139func (wc * workflowClient ) SignalWorkflow (workflowID string , runID string , signalName string , arg interface {}) error {
140- input , err := getHostEnvironment ().encodeArg (arg )
141- if err != nil {
142- return err
140+ var input []byte
141+ if arg != nil {
142+ var err error
143+ if input , err = getHostEnvironment ().encodeArg (arg ); err != nil {
144+ return err
145+ }
143146 }
147+
144148 request := & s.SignalWorkflowExecutionRequest {
145149 Domain : common .StringPtr (wc .domain ),
146150 WorkflowExecution : & s.WorkflowExecution {
147151 WorkflowId : common .StringPtr (workflowID ),
148- RunId : common . StringPtr (runID ),
152+ RunId : getRunID (runID ),
149153 },
150154 SignalName : common .StringPtr (signalName ),
151155 Input : input ,
@@ -166,7 +170,7 @@ func (wc *workflowClient) CancelWorkflow(workflowID string, runID string) error
166170 Domain : common .StringPtr (wc .domain ),
167171 WorkflowExecution : & s.WorkflowExecution {
168172 WorkflowId : common .StringPtr (workflowID ),
169- RunId : common . StringPtr (runID ),
173+ RunId : getRunID (runID ),
170174 },
171175 Identity : common .StringPtr (wc .identity ),
172176 }
@@ -187,7 +191,7 @@ func (wc *workflowClient) TerminateWorkflow(workflowID string, runID string, rea
187191 Domain : common .StringPtr (wc .domain ),
188192 WorkflowExecution : & s.WorkflowExecution {
189193 WorkflowId : common .StringPtr (workflowID ),
190- RunId : common . StringPtr (runID ),
194+ RunId : getRunID (runID ),
191195 },
192196 Reason : common .StringPtr (reason ),
193197 Identity : common .StringPtr (wc .identity ),
@@ -215,7 +219,7 @@ GetHistoryLoop:
215219 Domain : common .StringPtr (wc .domain ),
216220 Execution : & s.WorkflowExecution {
217221 WorkflowId : common .StringPtr (workflowID ),
218- RunId : common . StringPtr (runID ),
222+ RunId : getRunID (runID ),
219223 },
220224 NextPageToken : nextPageToken ,
221225 }
@@ -383,3 +387,11 @@ func (dc *domainClient) Update(name string, domainInfo *s.UpdateDomainInfo, doma
383387 return err
384388 }, serviceOperationRetryPolicy , isServiceTransientError )
385389}
390+
391+ func getRunID (runID string ) * string {
392+ if runID == "" {
393+ // Cadence Server will pick current runID if provided empty.
394+ return nil
395+ }
396+ return common .StringPtr (runID )
397+ }
0 commit comments