temporalio 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -0
  3. data/Cargo.lock +659 -370
  4. data/Cargo.toml +2 -2
  5. data/Gemfile +3 -3
  6. data/README.md +589 -47
  7. data/Rakefile +10 -296
  8. data/ext/Cargo.toml +1 -0
  9. data/lib/temporalio/activity/complete_async_error.rb +1 -1
  10. data/lib/temporalio/activity/context.rb +5 -2
  11. data/lib/temporalio/activity/definition.rb +163 -65
  12. data/lib/temporalio/activity/info.rb +22 -21
  13. data/lib/temporalio/activity.rb +2 -59
  14. data/lib/temporalio/api/activity/v1/message.rb +25 -0
  15. data/lib/temporalio/api/cloud/account/v1/message.rb +28 -0
  16. data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +34 -1
  17. data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +1 -1
  18. data/lib/temporalio/api/cloud/identity/v1/message.rb +6 -1
  19. data/lib/temporalio/api/cloud/namespace/v1/message.rb +8 -1
  20. data/lib/temporalio/api/cloud/nexus/v1/message.rb +31 -0
  21. data/lib/temporalio/api/cloud/operation/v1/message.rb +2 -1
  22. data/lib/temporalio/api/cloud/region/v1/message.rb +2 -1
  23. data/lib/temporalio/api/cloud/resource/v1/message.rb +23 -0
  24. data/lib/temporalio/api/cloud/sink/v1/message.rb +24 -0
  25. data/lib/temporalio/api/cloud/usage/v1/message.rb +31 -0
  26. data/lib/temporalio/api/common/v1/message.rb +7 -1
  27. data/lib/temporalio/api/enums/v1/event_type.rb +1 -1
  28. data/lib/temporalio/api/enums/v1/failed_cause.rb +1 -1
  29. data/lib/temporalio/api/enums/v1/reset.rb +1 -1
  30. data/lib/temporalio/api/history/v1/message.rb +1 -1
  31. data/lib/temporalio/api/nexus/v1/message.rb +2 -2
  32. data/lib/temporalio/api/operatorservice/v1/service.rb +1 -1
  33. data/lib/temporalio/api/payload_visitor.rb +1513 -0
  34. data/lib/temporalio/api/schedule/v1/message.rb +2 -1
  35. data/lib/temporalio/api/testservice/v1/request_response.rb +31 -0
  36. data/lib/temporalio/api/testservice/v1/service.rb +23 -0
  37. data/lib/temporalio/api/workflow/v1/message.rb +1 -1
  38. data/lib/temporalio/api/workflowservice/v1/request_response.rb +17 -2
  39. data/lib/temporalio/api/workflowservice/v1/service.rb +1 -1
  40. data/lib/temporalio/api.rb +1 -0
  41. data/lib/temporalio/cancellation.rb +34 -14
  42. data/lib/temporalio/client/async_activity_handle.rb +12 -37
  43. data/lib/temporalio/client/connection/cloud_service.rb +309 -231
  44. data/lib/temporalio/client/connection/operator_service.rb +36 -84
  45. data/lib/temporalio/client/connection/service.rb +6 -5
  46. data/lib/temporalio/client/connection/test_service.rb +111 -0
  47. data/lib/temporalio/client/connection/workflow_service.rb +264 -441
  48. data/lib/temporalio/client/connection.rb +90 -44
  49. data/lib/temporalio/client/interceptor.rb +160 -60
  50. data/lib/temporalio/client/schedule.rb +967 -0
  51. data/lib/temporalio/client/schedule_handle.rb +126 -0
  52. data/lib/temporalio/client/workflow_execution.rb +7 -10
  53. data/lib/temporalio/client/workflow_handle.rb +38 -95
  54. data/lib/temporalio/client/workflow_update_handle.rb +3 -5
  55. data/lib/temporalio/client.rb +122 -42
  56. data/lib/temporalio/common_enums.rb +17 -0
  57. data/lib/temporalio/converters/data_converter.rb +4 -7
  58. data/lib/temporalio/converters/failure_converter.rb +5 -3
  59. data/lib/temporalio/converters/payload_converter/composite.rb +4 -0
  60. data/lib/temporalio/converters/payload_converter.rb +6 -8
  61. data/lib/temporalio/converters/raw_value.rb +20 -0
  62. data/lib/temporalio/error/failure.rb +1 -1
  63. data/lib/temporalio/error.rb +10 -2
  64. data/lib/temporalio/internal/bridge/api/core_interface.rb +5 -1
  65. data/lib/temporalio/internal/bridge/api/nexus/nexus.rb +33 -0
  66. data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +5 -1
  67. data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +4 -1
  68. data/lib/temporalio/internal/bridge/client.rb +11 -6
  69. data/lib/temporalio/internal/bridge/testing.rb +20 -0
  70. data/lib/temporalio/internal/bridge/worker.rb +2 -0
  71. data/lib/temporalio/internal/bridge.rb +1 -1
  72. data/lib/temporalio/internal/client/implementation.rb +245 -70
  73. data/lib/temporalio/internal/metric.rb +122 -0
  74. data/lib/temporalio/internal/proto_utils.rb +86 -7
  75. data/lib/temporalio/internal/worker/activity_worker.rb +52 -24
  76. data/lib/temporalio/internal/worker/multi_runner.rb +51 -7
  77. data/lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb +54 -0
  78. data/lib/temporalio/internal/worker/workflow_instance/context.rb +329 -0
  79. data/lib/temporalio/internal/worker/workflow_instance/details.rb +44 -0
  80. data/lib/temporalio/internal/worker/workflow_instance/external_workflow_handle.rb +32 -0
  81. data/lib/temporalio/internal/worker/workflow_instance/externally_immutable_hash.rb +22 -0
  82. data/lib/temporalio/internal/worker/workflow_instance/handler_execution.rb +25 -0
  83. data/lib/temporalio/internal/worker/workflow_instance/handler_hash.rb +41 -0
  84. data/lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb +97 -0
  85. data/lib/temporalio/internal/worker/workflow_instance/inbound_implementation.rb +62 -0
  86. data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +415 -0
  87. data/lib/temporalio/internal/worker/workflow_instance/replay_safe_logger.rb +37 -0
  88. data/lib/temporalio/internal/worker/workflow_instance/replay_safe_metric.rb +40 -0
  89. data/lib/temporalio/internal/worker/workflow_instance/scheduler.rb +163 -0
  90. data/lib/temporalio/internal/worker/workflow_instance.rb +730 -0
  91. data/lib/temporalio/internal/worker/workflow_worker.rb +196 -0
  92. data/lib/temporalio/metric.rb +109 -0
  93. data/lib/temporalio/retry_policy.rb +37 -14
  94. data/lib/temporalio/runtime.rb +118 -75
  95. data/lib/temporalio/search_attributes.rb +80 -37
  96. data/lib/temporalio/testing/activity_environment.rb +2 -2
  97. data/lib/temporalio/testing/workflow_environment.rb +251 -5
  98. data/lib/temporalio/version.rb +1 -1
  99. data/lib/temporalio/worker/activity_executor/thread_pool.rb +9 -217
  100. data/lib/temporalio/worker/activity_executor.rb +3 -3
  101. data/lib/temporalio/worker/interceptor.rb +340 -66
  102. data/lib/temporalio/worker/thread_pool.rb +237 -0
  103. data/lib/temporalio/worker/workflow_executor/thread_pool.rb +230 -0
  104. data/lib/temporalio/worker/workflow_executor.rb +26 -0
  105. data/lib/temporalio/worker.rb +201 -30
  106. data/lib/temporalio/workflow/activity_cancellation_type.rb +20 -0
  107. data/lib/temporalio/workflow/child_workflow_cancellation_type.rb +21 -0
  108. data/lib/temporalio/workflow/child_workflow_handle.rb +43 -0
  109. data/lib/temporalio/workflow/definition.rb +566 -0
  110. data/lib/temporalio/workflow/external_workflow_handle.rb +41 -0
  111. data/lib/temporalio/workflow/future.rb +151 -0
  112. data/lib/temporalio/workflow/handler_unfinished_policy.rb +13 -0
  113. data/lib/temporalio/workflow/info.rb +82 -0
  114. data/lib/temporalio/workflow/parent_close_policy.rb +19 -0
  115. data/lib/temporalio/workflow/update_info.rb +20 -0
  116. data/lib/temporalio/workflow.rb +523 -0
  117. data/lib/temporalio.rb +4 -0
  118. data/temporalio.gemspec +2 -2
  119. metadata +50 -8
@@ -10,11 +10,12 @@ require 'google/protobuf/empty_pb'
10
10
  require 'temporalio/api/common/v1/message'
11
11
  require 'temporalio/api/enums/v1/workflow'
12
12
  require 'temporalio/api/failure/v1/message'
13
+ require 'temporalio/api/sdk/v1/user_metadata'
13
14
  require 'temporalio/internal/bridge/api/child_workflow/child_workflow'
14
15
  require 'temporalio/internal/bridge/api/common/common'
15
16
 
16
17
 
17
- descriptor_data = "\n;temporal/sdk/core/workflow_commands/workflow_commands.proto\x12\x19\x63oresdk.workflow_commands\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a%temporal/api/failure/v1/message.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a%temporal/sdk/core/common/common.proto\"\xf2\r\n\x0fWorkflowCommand\x12<\n\x0bstart_timer\x18\x01 \x01(\x0b\x32%.coresdk.workflow_commands.StartTimerH\x00\x12H\n\x11schedule_activity\x18\x02 \x01(\x0b\x32+.coresdk.workflow_commands.ScheduleActivityH\x00\x12\x42\n\x10respond_to_query\x18\x03 \x01(\x0b\x32&.coresdk.workflow_commands.QueryResultH\x00\x12S\n\x17request_cancel_activity\x18\x04 \x01(\x0b\x32\x30.coresdk.workflow_commands.RequestCancelActivityH\x00\x12>\n\x0c\x63\x61ncel_timer\x18\x05 \x01(\x0b\x32&.coresdk.workflow_commands.CancelTimerH\x00\x12[\n\x1b\x63omplete_workflow_execution\x18\x06 \x01(\x0b\x32\x34.coresdk.workflow_commands.CompleteWorkflowExecutionH\x00\x12S\n\x17\x66\x61il_workflow_execution\x18\x07 \x01(\x0b\x32\x30.coresdk.workflow_commands.FailWorkflowExecutionH\x00\x12g\n\"continue_as_new_workflow_execution\x18\x08 \x01(\x0b\x32\x39.coresdk.workflow_commands.ContinueAsNewWorkflowExecutionH\x00\x12W\n\x19\x63\x61ncel_workflow_execution\x18\t \x01(\x0b\x32\x32.coresdk.workflow_commands.CancelWorkflowExecutionH\x00\x12\x45\n\x10set_patch_marker\x18\n \x01(\x0b\x32).coresdk.workflow_commands.SetPatchMarkerH\x00\x12`\n\x1estart_child_workflow_execution\x18\x0b \x01(\x0b\x32\x36.coresdk.workflow_commands.StartChildWorkflowExecutionH\x00\x12\x62\n\x1f\x63\x61ncel_child_workflow_execution\x18\x0c \x01(\x0b\x32\x37.coresdk.workflow_commands.CancelChildWorkflowExecutionH\x00\x12w\n*request_cancel_external_workflow_execution\x18\r \x01(\x0b\x32\x41.coresdk.workflow_commands.RequestCancelExternalWorkflowExecutionH\x00\x12h\n\"signal_external_workflow_execution\x18\x0e \x01(\x0b\x32:.coresdk.workflow_commands.SignalExternalWorkflowExecutionH\x00\x12Q\n\x16\x63\x61ncel_signal_workflow\x18\x0f \x01(\x0b\x32/.coresdk.workflow_commands.CancelSignalWorkflowH\x00\x12S\n\x17schedule_local_activity\x18\x10 \x01(\x0b\x32\x30.coresdk.workflow_commands.ScheduleLocalActivityH\x00\x12^\n\x1drequest_cancel_local_activity\x18\x11 \x01(\x0b\x32\x35.coresdk.workflow_commands.RequestCancelLocalActivityH\x00\x12\x66\n!upsert_workflow_search_attributes\x18\x12 \x01(\x0b\x32\x39.coresdk.workflow_commands.UpsertWorkflowSearchAttributesH\x00\x12Y\n\x1amodify_workflow_properties\x18\x13 \x01(\x0b\x32\x33.coresdk.workflow_commands.ModifyWorkflowPropertiesH\x00\x12\x44\n\x0fupdate_response\x18\x14 \x01(\x0b\x32).coresdk.workflow_commands.UpdateResponseH\x00\x42\t\n\x07variant\"S\n\nStartTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x38\n\x15start_to_fire_timeout\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration\"\x1a\n\x0b\x43\x61ncelTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r\"\x84\x06\n\x10ScheduleActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12I\n\x07headers\x18\x06 \x03(\x0b\x32\x38.coresdk.workflow_commands.ScheduleActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0b \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0c \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12\x1e\n\x16\x64o_not_eagerly_execute\x18\x0e \x01(\x08\x12;\n\x11versioning_intent\x18\x0f \x01(\x0e\x32 .coresdk.common.VersioningIntent\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\"\xee\x05\n\x15ScheduleLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x0f\n\x07\x61ttempt\x18\x04 \x01(\r\x12:\n\x16original_schedule_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12N\n\x07headers\x18\x06 \x03(\x0b\x32=.coresdk.workflow_commands.ScheduleLocalActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0b \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x38\n\x15local_retry_threshold\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\"$\n\x15RequestCancelActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\")\n\x1aRequestCancelLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\"\x9c\x01\n\x0bQueryResult\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12<\n\tsucceeded\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_commands.QuerySuccessH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\t\n\x07variant\"A\n\x0cQuerySuccess\x12\x31\n\x08response\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\"L\n\x19\x43ompleteWorkflowExecution\x12/\n\x06result\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\"J\n\x15\x46\x61ilWorkflowExecution\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\"\xfb\x06\n\x1e\x43ontinueAsNewWorkflowExecution\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x12\n\ntask_queue\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x37\n\x14workflow_run_timeout\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration\x12Q\n\x04memo\x18\x06 \x03(\x0b\x32\x43.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.MemoEntry\x12W\n\x07headers\x18\x07 \x03(\x0b\x32\x46.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.HeadersEntry\x12j\n\x11search_attributes\x18\x08 \x03(\x0b\x32O.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.SearchAttributesEntry\x12\x39\n\x0cretry_policy\x18\t \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12;\n\x11versioning_intent\x18\n \x01(\x0e\x32 .coresdk.common.VersioningIntent\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aX\n\x15SearchAttributesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\"\x19\n\x17\x43\x61ncelWorkflowExecution\"6\n\x0eSetPatchMarker\x12\x10\n\x08patch_id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08\"\xe0\t\n\x1bStartChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x03 \x01(\t\x12\x15\n\rworkflow_type\x18\x04 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12.\n\x05input\x18\x06 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12=\n\x1aworkflow_execution_timeout\x18\x07 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x46\n\x13parent_close_policy\x18\n \x01(\x0e\x32).coresdk.child_workflow.ParentClosePolicy\x12N\n\x18workflow_id_reuse_policy\x18\x0c \x01(\x0e\x32,.temporal.api.enums.v1.WorkflowIdReusePolicy\x12\x39\n\x0cretry_policy\x18\r \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x15\n\rcron_schedule\x18\x0e \x01(\t\x12T\n\x07headers\x18\x0f \x03(\x0b\x32\x43.coresdk.workflow_commands.StartChildWorkflowExecution.HeadersEntry\x12N\n\x04memo\x18\x10 \x03(\x0b\x32@.coresdk.workflow_commands.StartChildWorkflowExecution.MemoEntry\x12g\n\x11search_attributes\x18\x11 \x03(\x0b\x32L.coresdk.workflow_commands.StartChildWorkflowExecution.SearchAttributesEntry\x12P\n\x11\x63\x61ncellation_type\x18\x12 \x01(\x0e\x32\x35.coresdk.child_workflow.ChildWorkflowCancellationType\x12;\n\x11versioning_intent\x18\x13 \x01(\x0e\x32 .coresdk.common.VersioningIntent\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aX\n\x15SearchAttributesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\":\n\x1c\x43\x61ncelChildWorkflowExecution\x12\x1a\n\x12\x63hild_workflow_seq\x18\x01 \x01(\r\"\xa7\x01\n&RequestCancelExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12I\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecutionH\x00\x12\x1b\n\x11\x63hild_workflow_id\x18\x03 \x01(\tH\x00\x42\x08\n\x06target\"\x8f\x03\n\x1fSignalExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12I\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecutionH\x00\x12\x1b\n\x11\x63hild_workflow_id\x18\x03 \x01(\tH\x00\x12\x13\n\x0bsignal_name\x18\x04 \x01(\t\x12-\n\x04\x61rgs\x18\x05 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12X\n\x07headers\x18\x06 \x03(\x0b\x32G.coresdk.workflow_commands.SignalExternalWorkflowExecution.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x42\x08\n\x06target\"#\n\x14\x43\x61ncelSignalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\"\xe6\x01\n\x1eUpsertWorkflowSearchAttributes\x12j\n\x11search_attributes\x18\x01 \x03(\x0b\x32O.coresdk.workflow_commands.UpsertWorkflowSearchAttributes.SearchAttributesEntry\x1aX\n\x15SearchAttributesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\"O\n\x18ModifyWorkflowProperties\x12\x33\n\rupserted_memo\x18\x01 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo\"\xd2\x01\n\x0eUpdateResponse\x12\x1c\n\x14protocol_instance_id\x18\x01 \x01(\t\x12*\n\x08\x61\x63\x63\x65pted\x18\x02 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x12\x34\n\x08rejected\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12\x34\n\tcompleted\x18\x04 \x01(\x0b\x32\x1f.temporal.api.common.v1.PayloadH\x00\x42\n\n\x08response*X\n\x18\x41\x63tivityCancellationType\x12\x0e\n\nTRY_CANCEL\x10\x00\x12\x1f\n\x1bWAIT_CANCELLATION_COMPLETED\x10\x01\x12\x0b\n\x07\x41\x42\x41NDON\x10\x02\x42\x36\xea\x02\x33Temporalio::Internal::Bridge::Api::WorkflowCommandsb\x06proto3"
18
+ descriptor_data = "\n;temporal/sdk/core/workflow_commands/workflow_commands.proto\x12\x19\x63oresdk.workflow_commands\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a%temporal/api/failure/v1/message.proto\x1a\'temporal/api/sdk/v1/user_metadata.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a%temporal/sdk/core/common/common.proto\"\xe5\x0f\n\x0fWorkflowCommand\x12\x38\n\ruser_metadata\x18\x64 \x01(\x0b\x32!.temporal.api.sdk.v1.UserMetadata\x12<\n\x0bstart_timer\x18\x01 \x01(\x0b\x32%.coresdk.workflow_commands.StartTimerH\x00\x12H\n\x11schedule_activity\x18\x02 \x01(\x0b\x32+.coresdk.workflow_commands.ScheduleActivityH\x00\x12\x42\n\x10respond_to_query\x18\x03 \x01(\x0b\x32&.coresdk.workflow_commands.QueryResultH\x00\x12S\n\x17request_cancel_activity\x18\x04 \x01(\x0b\x32\x30.coresdk.workflow_commands.RequestCancelActivityH\x00\x12>\n\x0c\x63\x61ncel_timer\x18\x05 \x01(\x0b\x32&.coresdk.workflow_commands.CancelTimerH\x00\x12[\n\x1b\x63omplete_workflow_execution\x18\x06 \x01(\x0b\x32\x34.coresdk.workflow_commands.CompleteWorkflowExecutionH\x00\x12S\n\x17\x66\x61il_workflow_execution\x18\x07 \x01(\x0b\x32\x30.coresdk.workflow_commands.FailWorkflowExecutionH\x00\x12g\n\"continue_as_new_workflow_execution\x18\x08 \x01(\x0b\x32\x39.coresdk.workflow_commands.ContinueAsNewWorkflowExecutionH\x00\x12W\n\x19\x63\x61ncel_workflow_execution\x18\t \x01(\x0b\x32\x32.coresdk.workflow_commands.CancelWorkflowExecutionH\x00\x12\x45\n\x10set_patch_marker\x18\n \x01(\x0b\x32).coresdk.workflow_commands.SetPatchMarkerH\x00\x12`\n\x1estart_child_workflow_execution\x18\x0b \x01(\x0b\x32\x36.coresdk.workflow_commands.StartChildWorkflowExecutionH\x00\x12\x62\n\x1f\x63\x61ncel_child_workflow_execution\x18\x0c \x01(\x0b\x32\x37.coresdk.workflow_commands.CancelChildWorkflowExecutionH\x00\x12w\n*request_cancel_external_workflow_execution\x18\r \x01(\x0b\x32\x41.coresdk.workflow_commands.RequestCancelExternalWorkflowExecutionH\x00\x12h\n\"signal_external_workflow_execution\x18\x0e \x01(\x0b\x32:.coresdk.workflow_commands.SignalExternalWorkflowExecutionH\x00\x12Q\n\x16\x63\x61ncel_signal_workflow\x18\x0f \x01(\x0b\x32/.coresdk.workflow_commands.CancelSignalWorkflowH\x00\x12S\n\x17schedule_local_activity\x18\x10 \x01(\x0b\x32\x30.coresdk.workflow_commands.ScheduleLocalActivityH\x00\x12^\n\x1drequest_cancel_local_activity\x18\x11 \x01(\x0b\x32\x35.coresdk.workflow_commands.RequestCancelLocalActivityH\x00\x12\x66\n!upsert_workflow_search_attributes\x18\x12 \x01(\x0b\x32\x39.coresdk.workflow_commands.UpsertWorkflowSearchAttributesH\x00\x12Y\n\x1amodify_workflow_properties\x18\x13 \x01(\x0b\x32\x33.coresdk.workflow_commands.ModifyWorkflowPropertiesH\x00\x12\x44\n\x0fupdate_response\x18\x14 \x01(\x0b\x32).coresdk.workflow_commands.UpdateResponseH\x00\x12U\n\x18schedule_nexus_operation\x18\x15 \x01(\x0b\x32\x31.coresdk.workflow_commands.ScheduleNexusOperationH\x00\x12`\n\x1erequest_cancel_nexus_operation\x18\x16 \x01(\x0b\x32\x36.coresdk.workflow_commands.RequestCancelNexusOperationH\x00\x42\t\n\x07variant\"S\n\nStartTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x38\n\x15start_to_fire_timeout\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration\"\x1a\n\x0b\x43\x61ncelTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r\"\x84\x06\n\x10ScheduleActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12I\n\x07headers\x18\x06 \x03(\x0b\x32\x38.coresdk.workflow_commands.ScheduleActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0b \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0c \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12\x1e\n\x16\x64o_not_eagerly_execute\x18\x0e \x01(\x08\x12;\n\x11versioning_intent\x18\x0f \x01(\x0e\x32 .coresdk.common.VersioningIntent\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\"\xee\x05\n\x15ScheduleLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x0f\n\x07\x61ttempt\x18\x04 \x01(\r\x12:\n\x16original_schedule_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12N\n\x07headers\x18\x06 \x03(\x0b\x32=.coresdk.workflow_commands.ScheduleLocalActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0b \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x38\n\x15local_retry_threshold\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\"$\n\x15RequestCancelActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\")\n\x1aRequestCancelLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\"\x9c\x01\n\x0bQueryResult\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12<\n\tsucceeded\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_commands.QuerySuccessH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\t\n\x07variant\"A\n\x0cQuerySuccess\x12\x31\n\x08response\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\"L\n\x19\x43ompleteWorkflowExecution\x12/\n\x06result\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\"J\n\x15\x46\x61ilWorkflowExecution\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\"\xfb\x06\n\x1e\x43ontinueAsNewWorkflowExecution\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x12\n\ntask_queue\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x37\n\x14workflow_run_timeout\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration\x12Q\n\x04memo\x18\x06 \x03(\x0b\x32\x43.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.MemoEntry\x12W\n\x07headers\x18\x07 \x03(\x0b\x32\x46.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.HeadersEntry\x12j\n\x11search_attributes\x18\x08 \x03(\x0b\x32O.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.SearchAttributesEntry\x12\x39\n\x0cretry_policy\x18\t \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12;\n\x11versioning_intent\x18\n \x01(\x0e\x32 .coresdk.common.VersioningIntent\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aX\n\x15SearchAttributesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\"\x19\n\x17\x43\x61ncelWorkflowExecution\"6\n\x0eSetPatchMarker\x12\x10\n\x08patch_id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08\"\xe0\t\n\x1bStartChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x03 \x01(\t\x12\x15\n\rworkflow_type\x18\x04 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12.\n\x05input\x18\x06 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12=\n\x1aworkflow_execution_timeout\x18\x07 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x46\n\x13parent_close_policy\x18\n \x01(\x0e\x32).coresdk.child_workflow.ParentClosePolicy\x12N\n\x18workflow_id_reuse_policy\x18\x0c \x01(\x0e\x32,.temporal.api.enums.v1.WorkflowIdReusePolicy\x12\x39\n\x0cretry_policy\x18\r \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x15\n\rcron_schedule\x18\x0e \x01(\t\x12T\n\x07headers\x18\x0f \x03(\x0b\x32\x43.coresdk.workflow_commands.StartChildWorkflowExecution.HeadersEntry\x12N\n\x04memo\x18\x10 \x03(\x0b\x32@.coresdk.workflow_commands.StartChildWorkflowExecution.MemoEntry\x12g\n\x11search_attributes\x18\x11 \x03(\x0b\x32L.coresdk.workflow_commands.StartChildWorkflowExecution.SearchAttributesEntry\x12P\n\x11\x63\x61ncellation_type\x18\x12 \x01(\x0e\x32\x35.coresdk.child_workflow.ChildWorkflowCancellationType\x12;\n\x11versioning_intent\x18\x13 \x01(\x0e\x32 .coresdk.common.VersioningIntent\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aX\n\x15SearchAttributesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\":\n\x1c\x43\x61ncelChildWorkflowExecution\x12\x1a\n\x12\x63hild_workflow_seq\x18\x01 \x01(\r\"~\n&RequestCancelExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12G\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\"\x8f\x03\n\x1fSignalExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12I\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecutionH\x00\x12\x1b\n\x11\x63hild_workflow_id\x18\x03 \x01(\tH\x00\x12\x13\n\x0bsignal_name\x18\x04 \x01(\t\x12-\n\x04\x61rgs\x18\x05 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12X\n\x07headers\x18\x06 \x03(\x0b\x32G.coresdk.workflow_commands.SignalExternalWorkflowExecution.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x42\x08\n\x06target\"#\n\x14\x43\x61ncelSignalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\"\xe6\x01\n\x1eUpsertWorkflowSearchAttributes\x12j\n\x11search_attributes\x18\x01 \x03(\x0b\x32O.coresdk.workflow_commands.UpsertWorkflowSearchAttributes.SearchAttributesEntry\x1aX\n\x15SearchAttributesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\"O\n\x18ModifyWorkflowProperties\x12\x33\n\rupserted_memo\x18\x01 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo\"\xd2\x01\n\x0eUpdateResponse\x12\x1c\n\x14protocol_instance_id\x18\x01 \x01(\t\x12*\n\x08\x61\x63\x63\x65pted\x18\x02 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x12\x34\n\x08rejected\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12\x34\n\tcompleted\x18\x04 \x01(\x0b\x32\x1f.temporal.api.common.v1.PayloadH\x00\x42\n\n\x08response\"\xd7\x02\n\x16ScheduleNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x10\n\x08\x65ndpoint\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x11\n\toperation\x18\x04 \x01(\t\x12.\n\x05input\x18\x05 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12X\n\x0cnexus_header\x18\x07 \x03(\x0b\x32\x42.coresdk.workflow_commands.ScheduleNexusOperation.NexusHeaderEntry\x1a\x32\n\x10NexusHeaderEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"*\n\x1bRequestCancelNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r*X\n\x18\x41\x63tivityCancellationType\x12\x0e\n\nTRY_CANCEL\x10\x00\x12\x1f\n\x1bWAIT_CANCELLATION_COMPLETED\x10\x01\x12\x0b\n\x07\x41\x42\x41NDON\x10\x02\x42\x36\xea\x02\x33Temporalio::Internal::Bridge::Api::WorkflowCommandsb\x06proto3"
18
19
 
19
20
  pool = Google::Protobuf::DescriptorPool.generated_pool
20
21
  pool.add_serialized_file(descriptor_data)
@@ -46,6 +47,8 @@ module Temporalio
46
47
  UpsertWorkflowSearchAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_commands.UpsertWorkflowSearchAttributes").msgclass
47
48
  ModifyWorkflowProperties = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_commands.ModifyWorkflowProperties").msgclass
48
49
  UpdateResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_commands.UpdateResponse").msgclass
50
+ ScheduleNexusOperation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_commands.ScheduleNexusOperation").msgclass
51
+ RequestCancelNexusOperation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_commands.RequestCancelNexusOperation").msgclass
49
52
  ActivityCancellationType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_commands.ActivityCancellationType").enummodule
50
53
  end
51
54
  end
@@ -65,18 +65,23 @@ module Temporalio
65
65
  rpc:,
66
66
  request:,
67
67
  response_class:,
68
- rpc_retry:,
69
- rpc_metadata:,
70
- rpc_timeout:
68
+ rpc_options:
71
69
  )
70
+ # Build cancellation token if needed
71
+ if rpc_options&.cancellation
72
+ rpc_cancellation_token = CancellationToken.new
73
+ rpc_options&.cancellation&.add_cancel_callback { rpc_cancellation_token.cancel }
74
+ end
75
+
72
76
  queue = Queue.new
73
77
  async_invoke_rpc(
74
78
  service:,
75
79
  rpc:,
76
80
  request: request.to_proto,
77
- rpc_retry:,
78
- rpc_metadata:,
79
- rpc_timeout:,
81
+ rpc_retry: rpc_options&.override_retry || false,
82
+ rpc_metadata: rpc_options&.metadata,
83
+ rpc_timeout: rpc_options&.timeout,
84
+ rpc_cancellation_token:,
80
85
  queue:
81
86
  )
82
87
  result = queue.pop
@@ -24,6 +24,17 @@ module Temporalio
24
24
  keyword_init: true
25
25
  )
26
26
 
27
+ StartTestServerOptions = Struct.new(
28
+ :existing_path, # Optional
29
+ :sdk_name,
30
+ :sdk_version,
31
+ :download_version,
32
+ :download_dest_dir, # Optional
33
+ :port, # Optional
34
+ :extra_args,
35
+ keyword_init: true
36
+ )
37
+
27
38
  def self.start_dev_server(runtime, options)
28
39
  queue = Queue.new
29
40
  async_start_dev_server(runtime, options, queue)
@@ -33,6 +44,15 @@ module Temporalio
33
44
  result
34
45
  end
35
46
 
47
+ def self.start_test_server(runtime, options)
48
+ queue = Queue.new
49
+ async_start_test_server(runtime, options, queue)
50
+ result = queue.pop
51
+ raise result if result.is_a?(Exception)
52
+
53
+ result
54
+ end
55
+
36
56
  def shutdown
37
57
  queue = Queue.new
38
58
  async_shutdown(queue)
@@ -26,6 +26,8 @@ module Temporalio
26
26
  :max_task_queue_activities_per_second,
27
27
  :graceful_shutdown_period,
28
28
  :use_worker_versioning,
29
+ :nondeterminism_as_workflow_fail,
30
+ :nondeterminism_as_workflow_fail_for_types,
29
31
  keyword_init: true
30
32
  )
31
33
 
@@ -3,9 +3,9 @@
3
3
  # Use Ruby-version-specific Rust library if present. When the gem is compiled
4
4
  # via the cross-gem action, it is placed in a version specific directory. E.g.
5
5
  # for the Linux gem as of this writing, there will be files at:
6
- # * temporalio/internal/bridge/3.1/temporalio_bridge.so
7
6
  # * temporalio/internal/bridge/3.2/temporalio_bridge.so
8
7
  # * temporalio/internal/bridge/3.3/temporalio_bridge.so
8
+ # * temporalio/internal/bridge/3.4/temporalio_bridge.so
9
9
  # We fallback to just temporalio/internal/bridge/temporalio_bridge.so because
10
10
  # rake compile puts it there during manual build/development.
11
11
  begin
@@ -7,6 +7,8 @@ require 'temporalio/client/activity_id_reference'
7
7
  require 'temporalio/client/async_activity_handle'
8
8
  require 'temporalio/client/connection'
9
9
  require 'temporalio/client/interceptor'
10
+ require 'temporalio/client/schedule'
11
+ require 'temporalio/client/schedule_handle'
10
12
  require 'temporalio/client/workflow_execution'
11
13
  require 'temporalio/client/workflow_execution_count'
12
14
  require 'temporalio/client/workflow_handle'
@@ -17,11 +19,27 @@ require 'temporalio/error/failure'
17
19
  require 'temporalio/internal/proto_utils'
18
20
  require 'temporalio/runtime'
19
21
  require 'temporalio/search_attributes'
22
+ require 'temporalio/workflow/definition'
20
23
 
21
24
  module Temporalio
22
25
  module Internal
23
26
  module Client
24
27
  class Implementation < Temporalio::Client::Interceptor::Outbound
28
+ def self.with_default_rpc_options(user_rpc_options)
29
+ # If the user did not provide an override_retry, we need to make sure
30
+ # we use an option set that has it as "true"
31
+ if user_rpc_options.nil?
32
+ user_rpc_options = @always_retry_options ||= Temporalio::Client::RPCOptions.new(override_retry: true)
33
+ elsif !user_rpc_options.is_a?(Temporalio::Client::RPCOptions)
34
+ raise ArgumentError, 'rpc_options must be RPCOptions'
35
+ elsif user_rpc_options.override_retry.nil?
36
+ # Copy and set as true
37
+ user_rpc_options = user_rpc_options.dup
38
+ user_rpc_options.override_retry = true
39
+ end
40
+ user_rpc_options
41
+ end
42
+
25
43
  def initialize(client)
26
44
  super(nil)
27
45
  @client = client
@@ -32,7 +50,9 @@ module Temporalio
32
50
  req = Api::WorkflowService::V1::StartWorkflowExecutionRequest.new(
33
51
  request_id: SecureRandom.uuid,
34
52
  namespace: @client.namespace,
35
- workflow_type: Api::Common::V1::WorkflowType.new(name: input.workflow.to_s),
53
+ workflow_type: Api::Common::V1::WorkflowType.new(
54
+ name: Workflow::Definition._workflow_type_from_workflow_parameter(input.workflow)
55
+ ),
36
56
  workflow_id: input.workflow_id,
37
57
  task_queue: Api::TaskQueue::V1::TaskQueue.new(name: input.task_queue.to_s),
38
58
  input: @client.data_converter.to_payloads(input.args),
@@ -42,22 +62,20 @@ module Temporalio
42
62
  identity: @client.connection.identity,
43
63
  workflow_id_reuse_policy: input.id_reuse_policy,
44
64
  workflow_id_conflict_policy: input.id_conflict_policy,
45
- retry_policy: input.retry_policy&.to_proto,
65
+ retry_policy: input.retry_policy&._to_proto,
46
66
  cron_schedule: input.cron_schedule,
47
67
  memo: ProtoUtils.memo_to_proto(input.memo, @client.data_converter),
48
- search_attributes: input.search_attributes&.to_proto,
68
+ search_attributes: input.search_attributes&._to_proto,
49
69
  workflow_start_delay: ProtoUtils.seconds_to_duration(input.start_delay),
50
70
  request_eager_execution: input.request_eager_start,
51
- header: input.headers
71
+ header: ProtoUtils.headers_to_proto(input.headers, @client.data_converter)
52
72
  )
53
73
 
54
74
  # Send request
55
75
  begin
56
76
  resp = @client.workflow_service.start_workflow_execution(
57
77
  req,
58
- rpc_retry: true,
59
- rpc_metadata: input.rpc_metadata,
60
- rpc_timeout: input.rpc_timeout
78
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
61
79
  )
62
80
  rescue Error::RPCError => e
63
81
  # Unpack and raise already started if that's the error, otherwise default raise
@@ -95,9 +113,7 @@ module Temporalio
95
113
  loop do
96
114
  resp = @client.workflow_service.list_workflow_executions(
97
115
  req,
98
- rpc_retry: true,
99
- rpc_metadata: input.rpc_metadata,
100
- rpc_timeout: input.rpc_timeout
116
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
101
117
  )
102
118
  resp.executions.each do |raw_info|
103
119
  yielder << Temporalio::Client::WorkflowExecution.new(raw_info, @client.data_converter)
@@ -115,16 +131,14 @@ module Temporalio
115
131
  namespace: @client.namespace,
116
132
  query: input.query || ''
117
133
  ),
118
- rpc_retry: true,
119
- rpc_metadata: input.rpc_metadata,
120
- rpc_timeout: input.rpc_timeout
134
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
121
135
  )
122
136
  Temporalio::Client::WorkflowExecutionCount.new(
123
137
  resp.count,
124
138
  resp.groups.map do |group|
125
139
  Temporalio::Client::WorkflowExecutionCount::AggregationGroup.new(
126
140
  group.count,
127
- group.group_values.map { |payload| SearchAttributes.value_from_payload(payload) }
141
+ group.group_values.map { |payload| SearchAttributes._value_from_payload(payload) }
128
142
  )
129
143
  end
130
144
  )
@@ -139,9 +153,7 @@ module Temporalio
139
153
  run_id: input.run_id || ''
140
154
  )
141
155
  ),
142
- rpc_retry: true,
143
- rpc_metadata: input.rpc_metadata,
144
- rpc_timeout: input.rpc_timeout
156
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
145
157
  )
146
158
  Temporalio::Client::WorkflowExecution::Description.new(resp, @client.data_converter)
147
159
  end
@@ -161,9 +173,7 @@ module Temporalio
161
173
  loop do
162
174
  resp = @client.workflow_service.get_workflow_execution_history(
163
175
  req,
164
- rpc_retry: true,
165
- rpc_metadata: input.rpc_metadata,
166
- rpc_timeout: input.rpc_timeout
176
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
167
177
  )
168
178
  resp.history&.events&.each { |event| yielder << event }
169
179
  break if resp.next_page_token.empty?
@@ -181,15 +191,13 @@ module Temporalio
181
191
  workflow_id: input.workflow_id,
182
192
  run_id: input.run_id || ''
183
193
  ),
184
- signal_name: input.signal,
194
+ signal_name: Workflow::Definition::Signal._name_from_parameter(input.signal),
185
195
  input: @client.data_converter.to_payloads(input.args),
186
- header: input.headers,
196
+ header: Internal::ProtoUtils.headers_to_proto(input.headers, @client.data_converter),
187
197
  identity: @client.connection.identity,
188
198
  request_id: SecureRandom.uuid
189
199
  ),
190
- rpc_retry: true,
191
- rpc_metadata: input.rpc_metadata,
192
- rpc_timeout: input.rpc_timeout
200
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
193
201
  )
194
202
  nil
195
203
  end
@@ -204,15 +212,13 @@ module Temporalio
204
212
  run_id: input.run_id || ''
205
213
  ),
206
214
  query: Api::Query::V1::WorkflowQuery.new(
207
- query_type: input.query,
215
+ query_type: Workflow::Definition::Query._name_from_parameter(input.query),
208
216
  query_args: @client.data_converter.to_payloads(input.args),
209
- header: input.headers
217
+ header: Internal::ProtoUtils.headers_to_proto(input.headers, @client.data_converter)
210
218
  ),
211
219
  query_reject_condition: input.reject_condition || 0
212
220
  ),
213
- rpc_retry: true,
214
- rpc_metadata: input.rpc_metadata,
215
- rpc_timeout: input.rpc_timeout
221
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
216
222
  )
217
223
  rescue Error::RPCError => e
218
224
  # If the status is INVALID_ARGUMENT, we can assume it's a query failed
@@ -249,9 +255,9 @@ module Temporalio
249
255
  identity: @client.connection.identity
250
256
  ),
251
257
  input: Api::Update::V1::Input.new(
252
- name: input.update,
258
+ name: Workflow::Definition::Update._name_from_parameter(input.update),
253
259
  args: @client.data_converter.to_payloads(input.args),
254
- header: input.headers
260
+ header: Internal::ProtoUtils.headers_to_proto(input.headers, @client.data_converter)
255
261
  )
256
262
  ),
257
263
  wait_policy: Api::Update::V1::WaitPolicy.new(
@@ -267,9 +273,7 @@ module Temporalio
267
273
  loop do
268
274
  resp = @client.workflow_service.update_workflow_execution(
269
275
  req,
270
- rpc_retry: true,
271
- rpc_metadata: input.rpc_metadata,
272
- rpc_timeout: input.rpc_timeout
276
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
273
277
  )
274
278
 
275
279
  # We're only done if the response stage is after the requested stage
@@ -295,8 +299,7 @@ module Temporalio
295
299
  workflow_id: input.workflow_id,
296
300
  run_id: input.run_id,
297
301
  update_id: input.update_id,
298
- rpc_metadata: input.rpc_metadata,
299
- rpc_timeout: input.rpc_timeout
302
+ rpc_options: input.rpc_options
300
303
  )
301
304
  )
302
305
  end
@@ -330,9 +333,7 @@ module Temporalio
330
333
  loop do
331
334
  resp = @client.workflow_service.poll_workflow_execution_update(
332
335
  req,
333
- rpc_retry: true,
334
- rpc_metadata: input.rpc_metadata,
335
- rpc_timeout: input.rpc_timeout
336
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
336
337
  )
337
338
  return resp.outcome if resp.outcome
338
339
  rescue Error::RPCError => e
@@ -357,9 +358,7 @@ module Temporalio
357
358
  identity: @client.connection.identity,
358
359
  request_id: SecureRandom.uuid
359
360
  ),
360
- rpc_retry: true,
361
- rpc_metadata: input.rpc_metadata,
362
- rpc_timeout: input.rpc_timeout
361
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
363
362
  )
364
363
  nil
365
364
  end
@@ -377,9 +376,201 @@ module Temporalio
377
376
  details: @client.data_converter.to_payloads(input.details),
378
377
  identity: @client.connection.identity
379
378
  ),
380
- rpc_retry: true,
381
- rpc_metadata: input.rpc_metadata,
382
- rpc_timeout: input.rpc_timeout
379
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
380
+ )
381
+ nil
382
+ end
383
+
384
+ def create_schedule(input)
385
+ if input.schedule.state.limited_actions && input.schedule.state.remaining_actions.zero?
386
+ raise 'Must set limited actions to false if there are no remaining actions set'
387
+ end
388
+ if !input.schedule.state.limited_actions && !input.schedule.state.remaining_actions.zero?
389
+ raise 'Must set limited actions to true if there are remaining actions set'
390
+ end
391
+
392
+ @client.workflow_service.create_schedule(
393
+ Api::WorkflowService::V1::CreateScheduleRequest.new(
394
+ namespace: @client.namespace,
395
+ schedule_id: input.id,
396
+ schedule: input.schedule._to_proto(@client.data_converter),
397
+ initial_patch: if input.trigger_immediately || !input.backfills.empty?
398
+ Api::Schedule::V1::SchedulePatch.new(
399
+ trigger_immediately: if input.trigger_immediately
400
+ Api::Schedule::V1::TriggerImmediatelyRequest.new(
401
+ overlap_policy: input.schedule.policy.overlap
402
+ )
403
+ end,
404
+ backfill_request: input.backfills.map(&:_to_proto)
405
+ )
406
+ end,
407
+ identity: @client.connection.identity,
408
+ request_id: SecureRandom.uuid,
409
+ memo: ProtoUtils.memo_to_proto(input.memo, @client.data_converter),
410
+ search_attributes: input.search_attributes&._to_proto
411
+ ),
412
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
413
+ )
414
+ Temporalio::Client::ScheduleHandle.new(client: @client, id: input.id)
415
+ rescue Error::RPCError => e
416
+ # Unpack and raise already started if that's the error, otherwise default raise
417
+ details = if e.code == Error::RPCError::Code::ALREADY_EXISTS && e.grpc_status.details.first
418
+ e.grpc_status.details.first.unpack(Api::ErrorDetails::V1::WorkflowExecutionAlreadyStartedFailure)
419
+ end
420
+ raise Error::ScheduleAlreadyRunningError if details
421
+
422
+ raise
423
+ end
424
+
425
+ def list_schedules(input)
426
+ Enumerator.new do |yielder|
427
+ req = Api::WorkflowService::V1::ListSchedulesRequest.new(
428
+ namespace: @client.namespace,
429
+ query: input.query || ''
430
+ )
431
+ loop do
432
+ resp = @client.workflow_service.list_schedules(
433
+ req,
434
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
435
+ )
436
+ resp.schedules.each do |raw_entry|
437
+ yielder << Temporalio::Client::Schedule::List::Description.new(
438
+ raw_entry:,
439
+ data_converter: @client.data_converter
440
+ )
441
+ end
442
+ break if resp.next_page_token.empty?
443
+
444
+ req.next_page_token = resp.next_page_token
445
+ end
446
+ end
447
+ end
448
+
449
+ def backfill_schedule(input)
450
+ @client.workflow_service.patch_schedule(
451
+ Api::WorkflowService::V1::PatchScheduleRequest.new(
452
+ namespace: @client.namespace,
453
+ schedule_id: input.id,
454
+ patch: Api::Schedule::V1::SchedulePatch.new(
455
+ backfill_request: input.backfills.map(&:_to_proto)
456
+ ),
457
+ identity: @client.connection.identity,
458
+ request_id: SecureRandom.uuid
459
+ ),
460
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
461
+ )
462
+ nil
463
+ end
464
+
465
+ def delete_schedule(input)
466
+ @client.workflow_service.delete_schedule(
467
+ Api::WorkflowService::V1::DeleteScheduleRequest.new(
468
+ namespace: @client.namespace,
469
+ schedule_id: input.id,
470
+ identity: @client.connection.identity
471
+ ),
472
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
473
+ )
474
+ nil
475
+ end
476
+
477
+ def describe_schedule(input)
478
+ Temporalio::Client::Schedule::Description.new(
479
+ id: input.id,
480
+ raw_description: @client.workflow_service.describe_schedule(
481
+ Api::WorkflowService::V1::DescribeScheduleRequest.new(
482
+ namespace: @client.namespace,
483
+ schedule_id: input.id
484
+ ),
485
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
486
+ ),
487
+ data_converter: @client.data_converter
488
+ )
489
+ end
490
+
491
+ def pause_schedule(input)
492
+ @client.workflow_service.patch_schedule(
493
+ Api::WorkflowService::V1::PatchScheduleRequest.new(
494
+ namespace: @client.namespace,
495
+ schedule_id: input.id,
496
+ patch: Api::Schedule::V1::SchedulePatch.new(pause: input.note),
497
+ identity: @client.connection.identity,
498
+ request_id: SecureRandom.uuid
499
+ ),
500
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
501
+ )
502
+ nil
503
+ end
504
+
505
+ def trigger_schedule(input)
506
+ @client.workflow_service.patch_schedule(
507
+ Api::WorkflowService::V1::PatchScheduleRequest.new(
508
+ namespace: @client.namespace,
509
+ schedule_id: input.id,
510
+ patch: Api::Schedule::V1::SchedulePatch.new(
511
+ trigger_immediately: Api::Schedule::V1::TriggerImmediatelyRequest.new(
512
+ overlap_policy: input.overlap || 0
513
+ )
514
+ ),
515
+ identity: @client.connection.identity,
516
+ request_id: SecureRandom.uuid
517
+ ),
518
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
519
+ )
520
+ nil
521
+ end
522
+
523
+ def unpause_schedule(input)
524
+ @client.workflow_service.patch_schedule(
525
+ Api::WorkflowService::V1::PatchScheduleRequest.new(
526
+ namespace: @client.namespace,
527
+ schedule_id: input.id,
528
+ patch: Api::Schedule::V1::SchedulePatch.new(unpause: input.note),
529
+ identity: @client.connection.identity,
530
+ request_id: SecureRandom.uuid
531
+ ),
532
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
533
+ )
534
+ nil
535
+ end
536
+
537
+ def update_schedule(input)
538
+ # TODO(cretz): This is supposed to be a retry-conflict loop, but we do
539
+ # not yet have a way to know update failure is due to conflict token
540
+ # mismatch
541
+ update = input.updater.call(
542
+ Temporalio::Client::Schedule::Update::Input.new(
543
+ description: Temporalio::Client::Schedule::Description.new(
544
+ id: input.id,
545
+ raw_description: @client.workflow_service.describe_schedule(
546
+ Api::WorkflowService::V1::DescribeScheduleRequest.new(
547
+ namespace: @client.namespace,
548
+ schedule_id: input.id
549
+ ),
550
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
551
+ ),
552
+ data_converter: @client.data_converter
553
+ )
554
+ )
555
+ )
556
+ # Do nothing if update is nil, fail if not an expected update
557
+ return nil if update.nil?
558
+
559
+ unless update.is_a?(Temporalio::Client::Schedule::Update)
560
+ raise TypeError,
561
+ 'Expected result of update block to be a Schedule::Update'
562
+ end
563
+
564
+ @client.workflow_service.update_schedule(
565
+ Api::WorkflowService::V1::UpdateScheduleRequest.new(
566
+ namespace: @client.namespace,
567
+ schedule_id: input.id,
568
+ schedule: update.schedule._to_proto(@client.data_converter),
569
+ search_attributes: update.search_attributes&._to_proto,
570
+ identity: @client.connection.identity,
571
+ request_id: SecureRandom.uuid
572
+ ),
573
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
383
574
  )
384
575
  nil
385
576
  end
@@ -395,9 +586,7 @@ module Temporalio
395
586
  identity: @client.connection.identity,
396
587
  details: @client.data_converter.to_payloads(input.details)
397
588
  ),
398
- rpc_retry: true,
399
- rpc_metadata: input.rpc_metadata,
400
- rpc_timeout: input.rpc_timeout
589
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
401
590
  )
402
591
  else
403
592
  @client.workflow_service.record_activity_task_heartbeat(
@@ -407,9 +596,7 @@ module Temporalio
407
596
  identity: @client.connection.identity,
408
597
  details: @client.data_converter.to_payloads(input.details)
409
598
  ),
410
- rpc_retry: true,
411
- rpc_metadata: input.rpc_metadata,
412
- rpc_timeout: input.rpc_timeout
599
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
413
600
  )
414
601
  end
415
602
  raise Error::AsyncActivityCanceledError if resp.cancel_requested
@@ -428,9 +615,7 @@ module Temporalio
428
615
  identity: @client.connection.identity,
429
616
  result: @client.data_converter.to_payloads([input.result])
430
617
  ),
431
- rpc_retry: true,
432
- rpc_metadata: input.rpc_metadata,
433
- rpc_timeout: input.rpc_timeout
618
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
434
619
  )
435
620
  else
436
621
  @client.workflow_service.respond_activity_task_completed(
@@ -440,9 +625,7 @@ module Temporalio
440
625
  identity: @client.connection.identity,
441
626
  result: @client.data_converter.to_payloads([input.result])
442
627
  ),
443
- rpc_retry: true,
444
- rpc_metadata: input.rpc_metadata,
445
- rpc_timeout: input.rpc_timeout
628
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
446
629
  )
447
630
  end
448
631
  nil
@@ -464,9 +647,7 @@ module Temporalio
464
647
  @client.data_converter.to_payloads(input.last_heartbeat_details)
465
648
  end
466
649
  ),
467
- rpc_retry: true,
468
- rpc_metadata: input.rpc_metadata,
469
- rpc_timeout: input.rpc_timeout
650
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
470
651
  )
471
652
  else
472
653
  @client.workflow_service.respond_activity_task_failed(
@@ -481,9 +662,7 @@ module Temporalio
481
662
  @client.data_converter.to_payloads(input.last_heartbeat_details)
482
663
  end
483
664
  ),
484
- rpc_retry: true,
485
- rpc_metadata: input.rpc_metadata,
486
- rpc_timeout: input.rpc_timeout
665
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
487
666
  )
488
667
  end
489
668
  nil
@@ -500,9 +679,7 @@ module Temporalio
500
679
  identity: @client.connection.identity,
501
680
  details: @client.data_converter.to_payloads(input.details)
502
681
  ),
503
- rpc_retry: true,
504
- rpc_metadata: input.rpc_metadata,
505
- rpc_timeout: input.rpc_timeout
682
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
506
683
  )
507
684
  else
508
685
  @client.workflow_service.respond_activity_task_canceled(
@@ -512,9 +689,7 @@ module Temporalio
512
689
  identity: @client.connection.identity,
513
690
  details: @client.data_converter.to_payloads(input.details)
514
691
  ),
515
- rpc_retry: true,
516
- rpc_metadata: input.rpc_metadata,
517
- rpc_timeout: input.rpc_timeout
692
+ rpc_options: Implementation.with_default_rpc_options(input.rpc_options)
518
693
  )
519
694
  end
520
695
  nil