Class: Cadence::Client::ThriftClient

Inherits:
Object
  • Object
show all
Defined in:
lib/cadence/client/thrift_client.rb

Constant Summary collapse

WORKFLOW_ID_REUSE_POLICY =
{
  allow_failed: CadenceThrift::WorkflowIdReusePolicy::AllowDuplicateFailedOnly,
  allow: CadenceThrift::WorkflowIdReusePolicy::AllowDuplicate,
  reject: CadenceThrift::WorkflowIdReusePolicy::RejectDuplicate
}.freeze
DEFAULT_OPTIONS =
{
  polling_ttl: 60 # 1 minute
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(host, port, identity, options = {}) ⇒ ThriftClient

Returns a new instance of ThriftClient.



20
21
22
23
24
25
# File 'lib/cadence/client/thrift_client.rb', line 20

def initialize(host, port, identity, options = {})
  @url = "http://#{host}:#{port}"
  @identity = identity
  @options = DEFAULT_OPTIONS.merge(options)
  @mutex = Mutex.new
end

Instance Method Details

#count_workflow_executionsObject

Raises:

  • (NotImplementedError)


299
300
301
# File 'lib/cadence/client/thrift_client.rb', line 299

def count_workflow_executions
  raise NotImplementedError
end

#deprecate_domain(name:) ⇒ Object



58
59
60
61
# File 'lib/cadence/client/thrift_client.rb', line 58

def deprecate_domain(name:)
  request = CadenceThrift::DeprecateDomainRequest.new(name: name)
  send_request('DeprecateDomain', request)
end

#describe_domain(name:) ⇒ Object



38
39
40
41
# File 'lib/cadence/client/thrift_client.rb', line 38

def describe_domain(name:)
  request = CadenceThrift::DescribeDomainRequest.new(name: name)
  send_request('DescribeDomain', request)
end

#describe_task_list(domain:, task_list:) ⇒ Object



330
331
332
333
334
335
336
337
338
339
340
# File 'lib/cadence/client/thrift_client.rb', line 330

def describe_task_list(domain:, task_list:)
  request = CadenceThrift::DescribeTaskListRequest.new(
    domain: domain,
    taskList: CadenceThrift::TaskList.new(
      name: task_list
    ),
    taskListType: CadenceThrift::TaskListType::Decision,
    includeTaskListStatus: true
  )
  send_request('DescribeTaskList', request)
end

#describe_workflow_execution(domain:, workflow_id:, run_id:) ⇒ Object



319
320
321
322
323
324
325
326
327
328
# File 'lib/cadence/client/thrift_client.rb', line 319

def describe_workflow_execution(domain:, workflow_id:, run_id:)
  request = CadenceThrift::DescribeWorkflowExecutionRequest.new(
    domain: domain,
    execution: CadenceThrift::WorkflowExecution.new(
      workflowId: workflow_id,
      runId: run_id
    )
  )
  send_request('DescribeWorkflowExecution', request)
end

#get_search_attributesObject

Raises:

  • (NotImplementedError)


303
304
305
# File 'lib/cadence/client/thrift_client.rb', line 303

def get_search_attributes
  raise NotImplementedError
end

#get_workflow_execution_history(domain:, workflow_id:, run_id:, next_page_token: nil) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/cadence/client/thrift_client.rb', line 105

def get_workflow_execution_history(domain:, workflow_id:, run_id:, next_page_token: nil)
  request = CadenceThrift::GetWorkflowExecutionHistoryRequest.new(
    domain: domain,
    execution: CadenceThrift::WorkflowExecution.new(
      workflowId: workflow_id,
      runId: run_id
    ),
    nextPageToken: next_page_token
  )

  send_request('GetWorkflowExecutionHistory', request)
end

#list_archived_workflow_executionsObject

Raises:

  • (NotImplementedError)


291
292
293
# File 'lib/cadence/client/thrift_client.rb', line 291

def list_archived_workflow_executions
  raise NotImplementedError
end

#list_closed_workflow_executionsObject

Raises:

  • (NotImplementedError)


283
284
285
# File 'lib/cadence/client/thrift_client.rb', line 283

def list_closed_workflow_executions
  raise NotImplementedError
end

#list_domains(page_size:) ⇒ Object



43
44
45
46
# File 'lib/cadence/client/thrift_client.rb', line 43

def list_domains(page_size:)
  request = CadenceThrift::ListDomainsRequest.new(pageSize: page_size)
  send_request('ListDomains', request)
end

#list_open_workflow_executionsObject

Raises:

  • (NotImplementedError)


279
280
281
# File 'lib/cadence/client/thrift_client.rb', line 279

def list_open_workflow_executions
  raise NotImplementedError
end

#list_workflow_executionsObject

Raises:

  • (NotImplementedError)


287
288
289
# File 'lib/cadence/client/thrift_client.rb', line 287

def list_workflow_executions
  raise NotImplementedError
end

#poll_for_activity_task(domain:, task_list:) ⇒ Object



148
149
150
151
152
153
154
155
156
157
# File 'lib/cadence/client/thrift_client.rb', line 148

def poll_for_activity_task(domain:, task_list:)
  request = CadenceThrift::PollForActivityTaskRequest.new(
    identity: identity,
    domain: domain,
    taskList: CadenceThrift::TaskList.new(
      name: task_list
    )
  )
  send_request('PollForActivityTask', request)
end

#poll_for_decision_task(domain:, task_list:) ⇒ Object



118
119
120
121
122
123
124
125
126
127
# File 'lib/cadence/client/thrift_client.rb', line 118

def poll_for_decision_task(domain:, task_list:)
  request = CadenceThrift::PollForDecisionTaskRequest.new(
    identity: identity,
    domain: domain,
    taskList: CadenceThrift::TaskList.new(
      name: task_list
    )
  )
  send_request('PollForDecisionTask', request)
end

#query_workflowObject

Raises:

  • (NotImplementedError)


315
316
317
# File 'lib/cadence/client/thrift_client.rb', line 315

def query_workflow
  raise NotImplementedError
end

#record_activity_task_heartbeat(task_token:, details: nil) ⇒ Object



159
160
161
162
163
164
165
166
# File 'lib/cadence/client/thrift_client.rb', line 159

def record_activity_task_heartbeat(task_token:, details: nil)
  request = CadenceThrift::RecordActivityTaskHeartbeatRequest.new(
    taskToken: task_token,
    details: JSON.serialize(details),
    identity: identity
  )
  send_request('RecordActivityTaskHeartbeat', request)
end

#record_activity_task_heartbeat_by_idObject

Raises:

  • (NotImplementedError)


168
169
170
# File 'lib/cadence/client/thrift_client.rb', line 168

def record_activity_task_heartbeat_by_id
  raise NotImplementedError
end

#register_domain(name:, description: nil, global: false, metrics: false, retention_period: 10) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/cadence/client/thrift_client.rb', line 27

def register_domain(name:, description: nil, global: false, metrics: false, retention_period: 10)
  request = CadenceThrift::RegisterDomainRequest.new(
    name: name,
    description: description,
    emitMetric: metrics,
    isGlobalDomain: global,
    workflowExecutionRetentionPeriodInDays: retention_period
  )
  send_request('RegisterDomain', request)
end

#request_cancel_workflow_executionObject

Raises:

  • (NotImplementedError)


229
230
231
# File 'lib/cadence/client/thrift_client.rb', line 229

def request_cancel_workflow_execution
  raise NotImplementedError
end

#reset_sticky_task_listObject

Raises:

  • (NotImplementedError)


311
312
313
# File 'lib/cadence/client/thrift_client.rb', line 311

def reset_sticky_task_list
  raise NotImplementedError
end

#reset_workflow_execution(domain:, workflow_id:, run_id:, reason:, decision_task_event_id:) ⇒ Object



251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/cadence/client/thrift_client.rb', line 251

def reset_workflow_execution(domain:, workflow_id:, run_id:, reason:, decision_task_event_id:)
  request = CadenceThrift::ResetWorkflowExecutionRequest.new(
    domain: domain,
    workflowExecution: CadenceThrift::WorkflowExecution.new(
      workflowId: workflow_id,
      runId: run_id
    ),
    reason: reason,
    decisionFinishEventId: decision_task_event_id,
    requestId: SecureRandom.uuid
  )
  send_request('ResetWorkflowExecution', request)
end

#respond_activity_task_canceled(task_token:, details: nil) ⇒ Object



216
217
218
219
220
221
222
223
# File 'lib/cadence/client/thrift_client.rb', line 216

def respond_activity_task_canceled(task_token:, details: nil)
  request = CadenceThrift::RespondActivityTaskCanceledRequest.new(
    taskToken: task_token,
    details: JSON.serialize(details),
    identity: identity
  )
  send_request('RespondActivityTaskCanceled', request)
end

#respond_activity_task_canceled_by_idObject

Raises:

  • (NotImplementedError)


225
226
227
# File 'lib/cadence/client/thrift_client.rb', line 225

def respond_activity_task_canceled_by_id
  raise NotImplementedError
end

#respond_activity_task_completed(task_token:, result:) ⇒ Object



172
173
174
175
176
177
178
179
# File 'lib/cadence/client/thrift_client.rb', line 172

def respond_activity_task_completed(task_token:, result:)
  request = CadenceThrift::RespondActivityTaskCompletedRequest.new(
    identity: identity,
    taskToken: task_token,
    result: JSON.serialize(result)
  )
  send_request('RespondActivityTaskCompleted', request)
end

#respond_activity_task_completed_by_id(domain:, activity_id:, workflow_id:, run_id:, result:) ⇒ Object



181
182
183
184
185
186
187
188
189
190
191
# File 'lib/cadence/client/thrift_client.rb', line 181

def respond_activity_task_completed_by_id(domain:, activity_id:, workflow_id:, run_id:, result:)
  request = CadenceThrift::RespondActivityTaskCompletedByIDRequest.new(
    identity: identity,
    domain: domain,
    workflowID: workflow_id,
    runID: run_id,
    activityID: activity_id,
    result: JSON.serialize(result)
  )
  send_request('RespondActivityTaskCompletedByID', request)
end

#respond_activity_task_failed(task_token:, reason:, details: nil) ⇒ Object



193
194
195
196
197
198
199
200
201
# File 'lib/cadence/client/thrift_client.rb', line 193

def respond_activity_task_failed(task_token:, reason:, details: nil)
  request = CadenceThrift::RespondActivityTaskFailedRequest.new(
    identity: identity,
    taskToken: task_token,
    reason: reason,
    details: JSON.serialize(details)
  )
  send_request('RespondActivityTaskFailed', request)
end

#respond_activity_task_failed_by_id(domain:, activity_id:, workflow_id:, run_id:, reason:, details: nil) ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/cadence/client/thrift_client.rb', line 203

def respond_activity_task_failed_by_id(domain:, activity_id:, workflow_id:, run_id:, reason:, details: nil)
  request = CadenceThrift::RespondActivityTaskFailedByIDRequest.new(
    identity: identity,
    domain: domain,
    workflowID: workflow_id,
    runID: run_id,
    activityID: activity_id,
    reason: reason,
    details: JSON.serialize(details)
  )
  send_request('RespondActivityTaskFailedByID', request)
end

#respond_decision_task_completed(task_token:, decisions:) ⇒ Object



129
130
131
132
133
134
135
136
# File 'lib/cadence/client/thrift_client.rb', line 129

def respond_decision_task_completed(task_token:, decisions:)
  request = CadenceThrift::RespondDecisionTaskCompletedRequest.new(
    identity: identity,
    taskToken: task_token,
    decisions: Array(decisions)
  )
  send_request('RespondDecisionTaskCompleted', request)
end

#respond_decision_task_failed(task_token:, cause:, details: nil) ⇒ Object



138
139
140
141
142
143
144
145
146
# File 'lib/cadence/client/thrift_client.rb', line 138

def respond_decision_task_failed(task_token:, cause:, details: nil)
  request = CadenceThrift::RespondDecisionTaskFailedRequest.new(
    identity: identity,
    taskToken: task_token,
    cause: cause,
    details: JSON.serialize(details)
  )
  send_request('RespondDecisionTaskFailed', request)
end

#respond_query_task_completedObject

Raises:

  • (NotImplementedError)


307
308
309
# File 'lib/cadence/client/thrift_client.rb', line 307

def respond_query_task_completed
  raise NotImplementedError
end

#scan_workflow_executionsObject

Raises:

  • (NotImplementedError)


295
296
297
# File 'lib/cadence/client/thrift_client.rb', line 295

def scan_workflow_executions
  raise NotImplementedError
end

#signal_with_start_workflow_executionObject

Raises:

  • (NotImplementedError)


247
248
249
# File 'lib/cadence/client/thrift_client.rb', line 247

def signal_with_start_workflow_execution
  raise NotImplementedError
end

#signal_workflow_execution(domain:, workflow_id:, run_id:, signal:, input: nil) ⇒ Object



233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/cadence/client/thrift_client.rb', line 233

def signal_workflow_execution(domain:, workflow_id:, run_id:, signal:, input: nil)
  request = CadenceThrift::SignalWorkflowExecutionRequest.new(
    domain: domain,
    workflowExecution: CadenceThrift::WorkflowExecution.new(
      workflowId: workflow_id,
      runId: run_id
    ),
    signalName: signal,
    input: JSON.serialize(input),
    identity: identity
  )
  send_request('SignalWorkflowExecution', request)
end

#start_workflow_execution(domain:, workflow_id:, workflow_name:, task_list:, input: nil, execution_timeout:, task_timeout:, workflow_id_reuse_policy: nil, headers: nil, cron_schedule: nil) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/cadence/client/thrift_client.rb', line 63

def start_workflow_execution(
  domain:,
  workflow_id:,
  workflow_name:,
  task_list:,
  input: nil,
  execution_timeout:,
  task_timeout:,
  workflow_id_reuse_policy: nil,
  headers: nil,
  cron_schedule: nil
)
  request = CadenceThrift::StartWorkflowExecutionRequest.new(
    identity: identity,
    domain: domain,
    workflowType: CadenceThrift::WorkflowType.new(
      name: workflow_name
    ),
    workflowId: workflow_id,
    taskList: CadenceThrift::TaskList.new(
      name: task_list
    ),
    input: JSON.serialize(input),
    executionStartToCloseTimeoutSeconds: execution_timeout,
    taskStartToCloseTimeoutSeconds: task_timeout,
    requestId: SecureRandom.uuid,
    header: CadenceThrift::Header.new(
      fields: headers
    ),
    cronSchedule: cron_schedule
  )

  if workflow_id_reuse_policy
    policy = WORKFLOW_ID_REUSE_POLICY[workflow_id_reuse_policy]
    raise Client::ArgumentError, 'Unknown workflow_id_reuse_policy specified' unless policy

    request.workflowIdReusePolicy = policy
  end

  send_request('StartWorkflowExecution', request)
end

#terminate_workflow_execution(domain:, workflow_id:, run_id:, reason:, details: nil) ⇒ Object



265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/cadence/client/thrift_client.rb', line 265

def terminate_workflow_execution(domain:, workflow_id:, run_id:, reason:, details: nil)
  request = CadenceThrift::TerminateWorkflowExecutionRequest.new(
    domain: domain,
    workflowExecution: CadenceThrift::WorkflowExecution.new(
      workflowId: workflow_id,
      runId: run_id
    ),
    reason: reason,
    details: JSON.serialize(details),
    identity: identity
  )
  send_request('TerminateWorkflowExecution', request)
end

#update_domain(name:, description:) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/cadence/client/thrift_client.rb', line 48

def update_domain(name:, description:)
  request = CadenceThrift::UpdateDomainRequest.new(
    name: name,
    updateInfo: CadenceThrift::UpdateDomainRequest.new(
      description: description
    )
  )
  send_request('UpdateDomain', request)
end