@temporalio/core-bridge 1.12.0 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/Cargo.lock +64 -119
  2. package/Cargo.toml +1 -1
  3. package/index.js +3 -2
  4. package/package.json +3 -3
  5. package/releases/aarch64-apple-darwin/index.node +0 -0
  6. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  7. package/releases/x86_64-apple-darwin/index.node +0 -0
  8. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  9. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  10. package/sdk-core/.cargo/config.toml +1 -2
  11. package/sdk-core/.github/workflows/per-pr.yml +2 -0
  12. package/sdk-core/AGENTS.md +7 -0
  13. package/sdk-core/Cargo.toml +9 -5
  14. package/sdk-core/README.md +6 -5
  15. package/sdk-core/client/Cargo.toml +3 -2
  16. package/sdk-core/client/src/lib.rs +17 -8
  17. package/sdk-core/client/src/metrics.rs +57 -23
  18. package/sdk-core/client/src/raw.rs +33 -15
  19. package/sdk-core/core/Cargo.toml +11 -9
  20. package/sdk-core/core/benches/workflow_replay.rs +114 -15
  21. package/sdk-core/core/src/core_tests/activity_tasks.rs +18 -18
  22. package/sdk-core/core/src/core_tests/child_workflows.rs +4 -4
  23. package/sdk-core/core/src/core_tests/determinism.rs +6 -6
  24. package/sdk-core/core/src/core_tests/local_activities.rs +20 -20
  25. package/sdk-core/core/src/core_tests/mod.rs +40 -5
  26. package/sdk-core/core/src/core_tests/queries.rs +25 -16
  27. package/sdk-core/core/src/core_tests/replay_flag.rs +3 -3
  28. package/sdk-core/core/src/core_tests/updates.rs +3 -3
  29. package/sdk-core/core/src/core_tests/workers.rs +9 -7
  30. package/sdk-core/core/src/core_tests/workflow_tasks.rs +40 -42
  31. package/sdk-core/core/src/ephemeral_server/mod.rs +1 -19
  32. package/sdk-core/core/src/lib.rs +10 -1
  33. package/sdk-core/core/src/pollers/poll_buffer.rs +2 -2
  34. package/sdk-core/core/src/replay/mod.rs +3 -3
  35. package/sdk-core/core/src/telemetry/metrics.rs +306 -152
  36. package/sdk-core/core/src/telemetry/mod.rs +11 -4
  37. package/sdk-core/core/src/telemetry/otel.rs +134 -131
  38. package/sdk-core/core/src/telemetry/prometheus_meter.rs +885 -0
  39. package/sdk-core/core/src/telemetry/prometheus_server.rs +48 -28
  40. package/sdk-core/core/src/test_help/mod.rs +27 -12
  41. package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +7 -7
  42. package/sdk-core/core/src/worker/activities.rs +4 -4
  43. package/sdk-core/core/src/worker/client/mocks.rs +10 -3
  44. package/sdk-core/core/src/worker/client.rs +68 -5
  45. package/sdk-core/core/src/worker/heartbeat.rs +229 -0
  46. package/sdk-core/core/src/worker/mod.rs +35 -14
  47. package/sdk-core/core/src/worker/tuner/resource_based.rs +4 -4
  48. package/sdk-core/core/src/worker/workflow/history_update.rs +71 -19
  49. package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +1 -2
  50. package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -1
  51. package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +31 -48
  52. package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +1 -2
  53. package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +3 -3
  54. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +4 -1
  55. package/sdk-core/core/src/worker/workflow/managed_run.rs +1 -1
  56. package/sdk-core/core/src/worker/workflow/mod.rs +15 -15
  57. package/sdk-core/core-api/Cargo.toml +2 -2
  58. package/sdk-core/core-api/src/envconfig.rs +204 -99
  59. package/sdk-core/core-api/src/lib.rs +9 -0
  60. package/sdk-core/core-api/src/telemetry/metrics.rs +548 -100
  61. package/sdk-core/core-api/src/worker.rs +11 -5
  62. package/sdk-core/core-c-bridge/Cargo.toml +49 -0
  63. package/sdk-core/core-c-bridge/build.rs +26 -0
  64. package/sdk-core/core-c-bridge/include/temporal-sdk-core-c-bridge.h +817 -0
  65. package/sdk-core/core-c-bridge/src/client.rs +679 -0
  66. package/sdk-core/core-c-bridge/src/lib.rs +245 -0
  67. package/sdk-core/core-c-bridge/src/metric.rs +682 -0
  68. package/sdk-core/core-c-bridge/src/random.rs +61 -0
  69. package/sdk-core/core-c-bridge/src/runtime.rs +445 -0
  70. package/sdk-core/core-c-bridge/src/testing.rs +282 -0
  71. package/sdk-core/core-c-bridge/src/tests/context.rs +644 -0
  72. package/sdk-core/core-c-bridge/src/tests/mod.rs +178 -0
  73. package/sdk-core/core-c-bridge/src/tests/utils.rs +108 -0
  74. package/sdk-core/core-c-bridge/src/worker.rs +1069 -0
  75. package/sdk-core/etc/deps.svg +64 -64
  76. package/sdk-core/sdk/src/activity_context.rs +6 -4
  77. package/sdk-core/sdk/src/lib.rs +49 -27
  78. package/sdk-core/sdk/src/workflow_future.rs +18 -25
  79. package/sdk-core/sdk-core-protos/protos/api_upstream/README.md +4 -0
  80. package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +0 -2
  81. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +630 -83
  82. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +632 -78
  83. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/batch/v1/message.proto +4 -4
  84. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +6 -4
  85. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +2 -2
  86. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +32 -2
  87. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +10 -1
  88. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/deployment.proto +26 -0
  89. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
  90. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +4 -4
  91. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
  92. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +47 -31
  93. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +4 -4
  94. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/schedule/v1/message.proto +7 -1
  95. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/worker/v1/message.proto +134 -0
  96. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +14 -11
  97. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +148 -37
  98. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +21 -0
  99. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +4 -4
  100. package/sdk-core/sdk-core-protos/src/history_builder.rs +9 -5
  101. package/sdk-core/sdk-core-protos/src/lib.rs +96 -6
  102. package/sdk-core/test-utils/src/lib.rs +11 -3
  103. package/sdk-core/tests/cloud_tests.rs +3 -3
  104. package/sdk-core/tests/heavy_tests.rs +11 -3
  105. package/sdk-core/tests/integ_tests/client_tests.rs +12 -13
  106. package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +1 -1
  107. package/sdk-core/tests/integ_tests/metrics_tests.rs +188 -83
  108. package/sdk-core/tests/integ_tests/polling_tests.rs +1 -1
  109. package/sdk-core/tests/integ_tests/queries_tests.rs +56 -40
  110. package/sdk-core/tests/integ_tests/update_tests.rs +2 -7
  111. package/sdk-core/tests/integ_tests/worker_tests.rs +3 -4
  112. package/sdk-core/tests/integ_tests/worker_versioning_tests.rs +3 -7
  113. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +3 -5
  114. package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +24 -17
  115. package/src/client.rs +6 -0
  116. package/src/metrics.rs +6 -6
@@ -1,162 +1,162 @@
1
1
  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
2
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
3
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <!-- Generated by graphviz version 7.0.4 (0)
4
+ <!-- Generated by graphviz version 13.0.1 (0)
5
5
  -->
6
6
  <!-- Pages: 1 -->
7
- <svg width="436pt" height="404pt"
8
- viewBox="0.00 0.00 436.26 404.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
7
+ <svg width="433pt" height="404pt"
8
+ viewBox="0.00 0.00 433.00 404.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
9
  <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 400)">
10
- <polygon fill="white" stroke="none" points="-4,4 -4,-400 432.26,-400 432.26,4 -4,4"/>
10
+ <polygon fill="white" stroke="none" points="-4,4 -4,-400 429.23,-400 429.23,4 -4,4"/>
11
11
  <!-- 0 -->
12
12
  <g id="node1" class="node">
13
13
  <title>0</title>
14
- <polygon fill="none" stroke="black" points="255,-396 139,-396 139,-360 255,-360 255,-396"/>
15
- <text text-anchor="middle" x="197" y="-374.3" font-family="Times,serif" font-size="14.00">temporal&#45;sdk&#45;core</text>
14
+ <polygon fill="none" stroke="black" points="239.5,-396 123.75,-396 123.75,-360 239.5,-360 239.5,-396"/>
15
+ <text xml:space="preserve" text-anchor="middle" x="181.62" y="-372.95" font-family="Times,serif" font-size="14.00">temporal&#45;sdk&#45;core</text>
16
16
  </g>
17
17
  <!-- 1 -->
18
18
  <g id="node2" class="node">
19
19
  <title>1</title>
20
- <polygon fill="none" stroke="black" points="58,-324 0,-324 0,-288 58,-288 58,-324"/>
21
- <text text-anchor="middle" x="29" y="-302.3" font-family="Times,serif" font-size="14.00">rustfsm</text>
20
+ <polygon fill="none" stroke="black" points="57.25,-324 0,-324 0,-288 57.25,-288 57.25,-324"/>
21
+ <text xml:space="preserve" text-anchor="middle" x="28.62" y="-300.95" font-family="Times,serif" font-size="14.00">rustfsm</text>
22
22
  </g>
23
23
  <!-- 0&#45;&gt;1 -->
24
24
  <g id="edge1" class="edge">
25
25
  <title>0&#45;&gt;1</title>
26
- <path fill="none" stroke="black" d="M155.04,-359.52C128.68,-348.53 94.87,-334.45 68.91,-323.63"/>
27
- <polygon fill="black" stroke="black" points="70.28,-320.41 59.7,-319.79 67.59,-326.87 70.28,-320.41"/>
26
+ <path fill="none" stroke="black" d="M143.41,-359.52C120.38,-348.98 91.12,-335.59 67.91,-324.97"/>
27
+ <polygon fill="black" stroke="black" points="69.64,-321.91 59.09,-320.94 66.72,-328.28 69.64,-321.91"/>
28
28
  </g>
29
29
  <!-- 3 -->
30
30
  <g id="node3" class="node">
31
31
  <title>3</title>
32
- <polygon fill="none" stroke="black" points="368,-108 268,-108 268,-72 368,-72 368,-108"/>
33
- <text text-anchor="middle" x="318" y="-86.3" font-family="Times,serif" font-size="14.00">temporal&#45;client</text>
32
+ <polygon fill="none" stroke="black" points="289.25,-180 190,-180 190,-144 289.25,-144 289.25,-180"/>
33
+ <text xml:space="preserve" text-anchor="middle" x="239.62" y="-156.95" font-family="Times,serif" font-size="14.00">temporal&#45;client</text>
34
34
  </g>
35
35
  <!-- 0&#45;&gt;3 -->
36
36
  <g id="edge2" class="edge">
37
37
  <title>0&#45;&gt;3</title>
38
- <path fill="none" stroke="black" d="M255.43,-370.58C312.02,-363.02 391.98,-348.3 411,-324 461.94,-258.91 386.25,-162.28 343.68,-116.65"/>
39
- <polygon fill="black" stroke="black" points="346.38,-114.4 336.95,-109.58 341.31,-119.23 346.38,-114.4"/>
38
+ <path fill="none" stroke="black" d="M186.27,-359.85C196.24,-323.07 219.76,-236.29 231.97,-191.24"/>
39
+ <polygon fill="black" stroke="black" points="235.32,-192.26 234.56,-181.69 228.56,-190.43 235.32,-192.26"/>
40
40
  </g>
41
41
  <!-- 4 -->
42
42
  <g id="node4" class="node">
43
43
  <title>4</title>
44
- <polygon fill="none" stroke="black" points="298.5,-36 143.5,-36 143.5,0 298.5,0 298.5,-36"/>
45
- <text text-anchor="middle" x="221" y="-14.3" font-family="Times,serif" font-size="14.00">temporal&#45;sdk&#45;core&#45;protos</text>
44
+ <polygon fill="none" stroke="black" points="346,-108 209.25,-108 209.25,-72 346,-72 346,-108"/>
45
+ <text xml:space="preserve" text-anchor="middle" x="277.62" y="-84.95" font-family="Times,serif" font-size="14.00">temporal&#45;sdk&#45;core&#45;api</text>
46
46
  </g>
47
47
  <!-- 0&#45;&gt;4 -->
48
- <g id="edge5" class="edge">
48
+ <g id="edge4" class="edge">
49
49
  <title>0&#45;&gt;4</title>
50
- <path fill="none" stroke="black" d="M170.41,-359.59C137.57,-335.74 86,-289.6 86,-235 86,-235 86,-235 86,-161 86,-107.38 137.19,-65.95 176.53,-42.03"/>
51
- <polygon fill="black" stroke="black" points="178.08,-45.18 184.93,-37.1 174.53,-39.14 178.08,-45.18"/>
50
+ <path fill="none" stroke="black" d="M239.96,-371.52C300.11,-364.52 387.94,-350.08 408.62,-324 463.57,-254.75 364.22,-159.56 309.77,-115.37"/>
51
+ <polygon fill="black" stroke="black" points="312,-112.66 301.99,-109.17 307.63,-118.14 312,-112.66"/>
52
52
  </g>
53
53
  <!-- 5 -->
54
54
  <g id="node5" class="node">
55
55
  <title>5</title>
56
- <polygon fill="none" stroke="black" points="289.5,-180 152.5,-180 152.5,-144 289.5,-144 289.5,-180"/>
57
- <text text-anchor="middle" x="221" y="-158.3" font-family="Times,serif" font-size="14.00">temporal&#45;sdk&#45;core&#45;api</text>
56
+ <polygon fill="none" stroke="black" points="258.62,-36 104.62,-36 104.62,0 258.62,0 258.62,-36"/>
57
+ <text xml:space="preserve" text-anchor="middle" x="181.62" y="-12.95" font-family="Times,serif" font-size="14.00">temporal&#45;sdk&#45;core&#45;protos</text>
58
58
  </g>
59
59
  <!-- 0&#45;&gt;5 -->
60
- <g id="edge4" class="edge">
60
+ <g id="edge5" class="edge">
61
61
  <title>0&#45;&gt;5</title>
62
- <path fill="none" stroke="black" d="M188.08,-359.89C173.64,-329.74 148.72,-265.64 169,-216 173.27,-205.55 180.7,-196.05 188.64,-188.07"/>
63
- <polygon fill="black" stroke="black" points="190.92,-190.72 195.87,-181.35 186.16,-185.59 190.92,-190.72"/>
62
+ <path fill="none" stroke="black" d="M159.84,-359.83C131.52,-335.39 85.62,-287.67 85.62,-235 85.62,-235 85.62,-235 85.62,-161 85.62,-113.27 123.32,-69.6 151.46,-43.65"/>
63
+ <polygon fill="black" stroke="black" points="153.58,-46.45 158.71,-37.18 148.92,-41.23 153.58,-46.45"/>
64
64
  </g>
65
65
  <!-- 6 -->
66
66
  <g id="node6" class="node">
67
67
  <title>6</title>
68
- <polygon fill="none" stroke="black" points="266.5,-252 177.5,-252 177.5,-216 266.5,-216 266.5,-252"/>
69
- <text text-anchor="middle" x="222" y="-230.3" font-family="Times,serif" font-size="14.00">temporal&#45;sdk</text>
68
+ <polygon fill="none" stroke="black" points="202.62,-252 114.62,-252 114.62,-216 202.62,-216 202.62,-252"/>
69
+ <text xml:space="preserve" text-anchor="middle" x="158.62" y="-228.95" font-family="Times,serif" font-size="14.00">temporal&#45;sdk</text>
70
70
  </g>
71
71
  <!-- 0&#45;&gt;6 -->
72
72
  <g id="edge3" class="edge">
73
73
  <title>0&#45;&gt;6</title>
74
- <path fill="none" stroke="blue" d="M195.45,-359.59C197.18,-335.5 204.59,-291.75 211.56,-263.03"/>
75
- <polygon fill="blue" stroke="blue" points="214.89,-264.13 214.02,-253.58 208.12,-262.37 214.89,-264.13"/>
74
+ <path fill="none" stroke="blue" d="M174.19,-359.59C167.81,-335.61 160.46,-292.14 157.7,-263.42"/>
75
+ <polygon fill="blue" stroke="blue" points="161.2,-263.32 156.93,-253.62 154.22,-263.86 161.2,-263.32"/>
76
76
  </g>
77
77
  <!-- 7 -->
78
78
  <g id="node7" class="node">
79
79
  <title>7</title>
80
- <polygon fill="none" stroke="black" points="401.5,-324 234.5,-324 234.5,-288 401.5,-288 401.5,-324"/>
81
- <text text-anchor="middle" x="318" y="-302.3" font-family="Times,serif" font-size="14.00">temporal&#45;sdk&#45;core&#45;test&#45;utils</text>
80
+ <polygon fill="none" stroke="black" points="400,-324 233.25,-324 233.25,-288 400,-288 400,-324"/>
81
+ <text xml:space="preserve" text-anchor="middle" x="316.62" y="-300.95" font-family="Times,serif" font-size="14.00">temporal&#45;sdk&#45;core&#45;test&#45;utils</text>
82
82
  </g>
83
83
  <!-- 0&#45;&gt;7 -->
84
84
  <g id="edge6" class="edge">
85
85
  <title>0&#45;&gt;7</title>
86
- <path fill="none" stroke="blue" d="M221.29,-359.52C235.94,-350.51 254.96,-339.42 272.29,-329.76"/>
87
- <polygon fill="blue" stroke="blue" points="273.86,-332.89 280.93,-324.99 270.48,-326.76 273.86,-332.89"/>
86
+ <path fill="none" stroke="blue" d="M209.41,-359.52C226.09,-350.39 247.7,-339.11 267.17,-329.35"/>
87
+ <polygon fill="blue" stroke="blue" points="268.67,-332.52 276.07,-324.93 265.56,-326.25 268.67,-332.52"/>
88
88
  </g>
89
89
  <!-- 3&#45;&gt;4 -->
90
90
  <g id="edge7" class="edge">
91
91
  <title>3&#45;&gt;4</title>
92
- <path fill="none" stroke="black" d="M294.02,-71.7C282.01,-63.03 267.28,-52.4 254.21,-42.96"/>
93
- <polygon fill="black" stroke="black" points="256.42,-40.25 246.27,-37.23 252.33,-45.92 256.42,-40.25"/>
92
+ <path fill="none" stroke="black" d="M249.02,-143.7C253.21,-135.98 258.24,-126.71 262.91,-118.11"/>
93
+ <polygon fill="black" stroke="black" points="265.92,-119.89 267.62,-109.43 259.77,-116.55 265.92,-119.89"/>
94
94
  </g>
95
- <!-- 5&#45;&gt;3 -->
95
+ <!-- 3&#45;&gt;5 -->
96
96
  <g id="edge8" class="edge">
97
- <title>5&#45;&gt;3</title>
98
- <path fill="none" stroke="black" d="M244.98,-143.7C256.99,-135.03 271.72,-124.4 284.79,-114.96"/>
99
- <polygon fill="black" stroke="black" points="286.67,-117.92 292.73,-109.23 282.58,-112.25 286.67,-117.92"/>
97
+ <title>3&#45;&gt;5</title>
98
+ <path fill="none" stroke="black" d="M223.84,-143.56C215.76,-133.76 206.43,-120.92 200.62,-108 192.01,-88.82 187.21,-65.53 184.6,-47.59"/>
99
+ <polygon fill="black" stroke="black" points="188.1,-47.37 183.34,-37.9 181.16,-48.27 188.1,-47.37"/>
100
100
  </g>
101
- <!-- 5&#45;&gt;4 -->
101
+ <!-- 4&#45;&gt;5 -->
102
102
  <g id="edge9" class="edge">
103
- <title>5&#45;&gt;4</title>
104
- <path fill="none" stroke="black" d="M221,-143.59C221,-119.61 221,-76.14 221,-47.42"/>
105
- <polygon fill="black" stroke="black" points="224.5,-47.62 221,-37.62 217.5,-47.62 224.5,-47.62"/>
103
+ <title>4&#45;&gt;5</title>
104
+ <path fill="none" stroke="black" d="M253.89,-71.7C242.01,-63.03 227.43,-52.4 214.49,-42.96"/>
105
+ <polygon fill="black" stroke="black" points="216.78,-40.3 206.64,-37.24 212.66,-45.96 216.78,-40.3"/>
106
106
  </g>
107
107
  <!-- 6&#45;&gt;0 -->
108
108
  <g id="edge11" class="edge">
109
109
  <title>6&#45;&gt;0</title>
110
- <path fill="none" stroke="black" d="M223.57,-252.11C221.89,-276.03 214.51,-319.76 207.53,-348.6"/>
111
- <polygon fill="black" stroke="black" points="204.18,-347.56 205.06,-358.12 210.96,-349.32 204.18,-347.56"/>
110
+ <path fill="none" stroke="black" d="M165.98,-252.11C172.36,-275.92 179.72,-319.37 182.51,-348.22"/>
111
+ <polygon fill="black" stroke="black" points="179.02,-348.39 183.3,-358.08 186,-347.83 179.02,-348.39"/>
112
112
  </g>
113
113
  <!-- 6&#45;&gt;3 -->
114
114
  <g id="edge10" class="edge">
115
115
  <title>6&#45;&gt;3</title>
116
- <path fill="none" stroke="black" d="M258.49,-215.67C273.19,-206.93 288.99,-194.98 299,-180 310.95,-162.11 315.57,-138.07 317.27,-119.49"/>
117
- <polygon fill="black" stroke="black" points="320.75,-119.9 317.91,-109.69 313.76,-119.44 320.75,-119.9"/>
116
+ <path fill="none" stroke="black" d="M178.65,-215.7C188.38,-207.28 200.26,-197.02 210.94,-187.79"/>
117
+ <polygon fill="black" stroke="black" points="213.13,-190.52 218.41,-181.34 208.55,-185.23 213.13,-190.52"/>
118
118
  </g>
119
119
  <!-- 6&#45;&gt;4 -->
120
- <g id="edge13" class="edge">
120
+ <g id="edge12" class="edge">
121
121
  <title>6&#45;&gt;4</title>
122
- <path fill="none" stroke="black" d="M181.41,-215.53C166.89,-207.06 152.12,-195.34 144,-180 136.51,-165.86 139.64,-159.39 144,-144 154.67,-106.33 180.26,-68.86 199.02,-44.92"/>
123
- <polygon fill="black" stroke="black" points="201.6,-47.29 205.13,-37.31 196.14,-42.91 201.6,-47.29"/>
122
+ <path fill="none" stroke="black" d="M158.87,-215.84C159.98,-196.51 164.4,-165.05 180.62,-144 190.33,-131.4 203.92,-121.4 217.86,-113.65"/>
123
+ <polygon fill="black" stroke="black" points="219.41,-116.79 226.68,-109.08 216.19,-110.57 219.41,-116.79"/>
124
124
  </g>
125
125
  <!-- 6&#45;&gt;5 -->
126
- <g id="edge12" class="edge">
126
+ <g id="edge13" class="edge">
127
127
  <title>6&#45;&gt;5</title>
128
- <path fill="none" stroke="black" d="M221.75,-215.7C221.65,-208.41 221.52,-199.73 221.41,-191.54"/>
129
- <polygon fill="black" stroke="black" points="224.91,-191.57 221.27,-181.62 217.91,-191.67 224.91,-191.57"/>
128
+ <path fill="none" stroke="black" d="M158.28,-215.56C158.09,-197.59 158.28,-168.77 160.62,-144 163.8,-110.53 170.66,-72.48 175.68,-47.24"/>
129
+ <polygon fill="black" stroke="black" points="179.05,-48.27 177.61,-37.77 172.19,-46.87 179.05,-48.27"/>
130
130
  </g>
131
131
  <!-- 7&#45;&gt;0 -->
132
132
  <g id="edge16" class="edge">
133
133
  <title>7&#45;&gt;0</title>
134
- <path fill="none" stroke="black" d="M294.08,-324.26C279.5,-333.23 260.5,-344.31 243.14,-354"/>
135
- <polygon fill="black" stroke="black" points="241.54,-350.89 234.48,-358.78 244.93,-357.01 241.54,-350.89"/>
134
+ <path fill="none" stroke="black" d="M289.25,-324.26C272.65,-333.36 251.07,-344.62 231.55,-354.41"/>
135
+ <polygon fill="black" stroke="black" points="230.03,-351.26 222.63,-358.84 233.15,-357.53 230.03,-351.26"/>
136
136
  </g>
137
137
  <!-- 7&#45;&gt;3 -->
138
138
  <g id="edge14" class="edge">
139
139
  <title>7&#45;&gt;3</title>
140
- <path fill="none" stroke="black" d="M318.57,-287.61C319.46,-258.08 320.99,-196.26 320,-144 319.85,-136.05 319.57,-127.44 319.27,-119.51"/>
141
- <polygon fill="black" stroke="black" points="322.78,-119.54 318.87,-109.69 315.78,-119.83 322.78,-119.54"/>
140
+ <path fill="none" stroke="black" d="M307.18,-287.59C293.95,-263.18 269.77,-218.58 254.21,-189.89"/>
141
+ <polygon fill="black" stroke="black" points="257.47,-188.56 249.62,-181.44 251.32,-191.9 257.47,-188.56"/>
142
142
  </g>
143
143
  <!-- 7&#45;&gt;4 -->
144
- <g id="edge18" class="edge">
144
+ <g id="edge17" class="edge">
145
145
  <title>7&#45;&gt;4</title>
146
- <path fill="none" stroke="black" d="M331.1,-287.73C360.65,-246.5 426.21,-140.69 377,-72 361.19,-49.92 335.65,-36.93 309.77,-29.32"/>
147
- <polygon fill="black" stroke="black" points="310.71,-25.95 300.15,-26.77 308.92,-32.72 310.71,-25.95"/>
146
+ <path fill="none" stroke="black" d="M316.2,-287.82C315.13,-258.08 311.41,-195.31 298.62,-144 296.54,-135.64 293.45,-126.85 290.27,-118.87"/>
147
+ <polygon fill="black" stroke="black" points="293.51,-117.54 286.41,-109.68 287.06,-120.25 293.51,-117.54"/>
148
148
  </g>
149
149
  <!-- 7&#45;&gt;5 -->
150
- <g id="edge17" class="edge">
150
+ <g id="edge18" class="edge">
151
151
  <title>7&#45;&gt;5</title>
152
- <path fill="none" stroke="black" d="M311.96,-287.6C304.98,-268.89 292.34,-238.77 276,-216 268.79,-205.96 259.54,-196.2 250.69,-187.86"/>
153
- <polygon fill="black" stroke="black" points="253.28,-185.48 243.53,-181.34 248.57,-190.66 253.28,-185.48"/>
152
+ <path fill="none" stroke="black" d="M327.2,-287.78C351.21,-246.21 404.1,-138.9 354.62,-72 334.91,-45.34 302.04,-31.66 270.22,-24.78"/>
153
+ <polygon fill="black" stroke="black" points="271,-21.36 260.51,-22.9 269.67,-28.24 271,-21.36"/>
154
154
  </g>
155
155
  <!-- 7&#45;&gt;6 -->
156
156
  <g id="edge15" class="edge">
157
157
  <title>7&#45;&gt;6</title>
158
- <path fill="none" stroke="black" d="M294.27,-287.7C282.38,-279.03 267.81,-268.4 254.86,-258.96"/>
159
- <polygon fill="black" stroke="black" points="257.16,-256.3 247.01,-253.24 253.03,-261.96 257.16,-256.3"/>
158
+ <path fill="none" stroke="black" d="M277.16,-287.52C256.25,-278.25 230.36,-266.78 208.12,-256.93"/>
159
+ <polygon fill="black" stroke="black" points="209.8,-253.85 199.24,-252.99 206.97,-260.25 209.8,-253.85"/>
160
160
  </g>
161
161
  </g>
162
162
  </svg>
@@ -149,10 +149,12 @@ impl ActContext {
149
149
 
150
150
  /// RecordHeartbeat sends heartbeat for the currently executing activity
151
151
  pub fn record_heartbeat(&self, details: Vec<Payload>) {
152
- self.worker.record_activity_heartbeat(ActivityHeartbeat {
153
- task_token: self.info.task_token.clone(),
154
- details,
155
- })
152
+ if !self.info.is_local {
153
+ self.worker.record_activity_heartbeat(ActivityHeartbeat {
154
+ task_token: self.info.task_token.clone(),
155
+ details,
156
+ })
157
+ }
156
158
  }
157
159
 
158
160
  /// Get activity info of the executing activity
@@ -109,6 +109,7 @@ use temporal_sdk_core_protos::{
109
109
  };
110
110
  use tokio::{
111
111
  sync::{
112
+ Notify,
112
113
  mpsc::{UnboundedSender, unbounded_channel},
113
114
  oneshot,
114
115
  },
@@ -151,6 +152,7 @@ struct WorkflowHalf {
151
152
  workflows: RefCell<HashMap<String, WorkflowData>>,
152
153
  /// Maps workflow type to the function for executing workflow runs with that ID
153
154
  workflow_fns: RefCell<HashMap<String, WorkflowFunction>>,
155
+ workflow_removed_from_map: Notify,
154
156
  }
155
157
  struct WorkflowData {
156
158
  /// Channel used to send the workflow activations
@@ -180,6 +182,7 @@ impl Worker {
180
182
  workflow_half: WorkflowHalf {
181
183
  workflows: Default::default(),
182
184
  workflow_fns: Default::default(),
185
+ workflow_removed_from_map: Default::default(),
183
186
  },
184
187
  activity_half: ActivityHalf {
185
188
  activity_fns: Default::default(),
@@ -260,6 +263,7 @@ impl Worker {
260
263
  join_handle.await??;
261
264
  debug!(run_id=%run_id, "Removing workflow from cache");
262
265
  wf_half.workflows.borrow_mut().remove(&run_id);
266
+ wf_half.workflow_removed_from_map.notify_one();
263
267
  Ok(())
264
268
  }
265
269
  },
@@ -293,12 +297,15 @@ impl Worker {
293
297
  if let Some(ref i) = common.worker_interceptor {
294
298
  i.on_workflow_activation(&activation).await?;
295
299
  }
296
- if let Some(wf_fut) = wf_half.workflow_activation_handler(
297
- common,
298
- shutdown_token.clone(),
299
- activation,
300
- &completions_tx,
301
- )? && wf_future_tx.send(wf_fut).is_err()
300
+ if let Some(wf_fut) = wf_half
301
+ .workflow_activation_handler(
302
+ common,
303
+ shutdown_token.clone(),
304
+ activation,
305
+ &completions_tx,
306
+ )
307
+ .await?
308
+ && wf_future_tx.send(wf_fut).is_err()
302
309
  {
303
310
  panic!("Receive half of completion processor channel cannot be dropped");
304
311
  }
@@ -384,7 +391,7 @@ impl Worker {
384
391
 
385
392
  impl WorkflowHalf {
386
393
  #[allow(clippy::type_complexity)]
387
- fn workflow_activation_handler(
394
+ async fn workflow_activation_handler(
388
395
  &self,
389
396
  common: &CommonWorker,
390
397
  shutdown_token: CancellationToken,
@@ -408,26 +415,29 @@ impl WorkflowHalf {
408
415
  _ => None,
409
416
  }) {
410
417
  let workflow_type = &sw.workflow_type;
411
- let wf_fns_borrow = self.workflow_fns.borrow();
412
- let Some(wf_function) = wf_fns_borrow.get(workflow_type) else {
413
- warn!("Workflow type {workflow_type} not found");
418
+ let (wff, activations) = {
419
+ let wf_fns_borrow = self.workflow_fns.borrow();
420
+
421
+ let Some(wf_function) = wf_fns_borrow.get(workflow_type) else {
422
+ warn!("Workflow type {workflow_type} not found");
423
+
424
+ completions_tx
425
+ .send(WorkflowActivationCompletion::fail(
426
+ run_id,
427
+ format!("Workflow type {workflow_type} not found").into(),
428
+ Some(WorkflowTaskFailedCause::WorkflowWorkerUnhandledFailure),
429
+ ))
430
+ .expect("Completion channel intact");
431
+ return Ok(None);
432
+ };
414
433
 
415
- completions_tx
416
- .send(WorkflowActivationCompletion::fail(
417
- run_id,
418
- format!("Workflow type {workflow_type} not found").into(),
419
- Some(WorkflowTaskFailedCause::WorkflowWorkerUnhandledFailure),
420
- ))
421
- .expect("Completion channel intact");
422
- return Ok(None);
434
+ wf_function.start_workflow(
435
+ common.worker.get_config().namespace.clone(),
436
+ common.task_queue.clone(),
437
+ std::mem::take(sw),
438
+ completions_tx.clone(),
439
+ )
423
440
  };
424
-
425
- let (wff, activations) = wf_function.start_workflow(
426
- common.worker.get_config().namespace.clone(),
427
- common.task_queue.clone(),
428
- std::mem::take(sw),
429
- completions_tx.clone(),
430
- );
431
441
  let jh = tokio::spawn(async move {
432
442
  tokio::select! {
433
443
  r = wff.fuse() => r,
@@ -442,6 +452,17 @@ impl WorkflowHalf {
442
452
  join_handle: jh,
443
453
  run_id: run_id.clone(),
444
454
  });
455
+ loop {
456
+ // It's possible that we've got a new initialize workflow action before the last
457
+ // future for this run finished evicting, as a result of how futures might be
458
+ // interleaved. In that case, just wait until it's not in the map, which should be
459
+ // a matter of only a few `poll` calls.
460
+ if self.workflows.borrow_mut().contains_key(&run_id) {
461
+ self.workflow_removed_from_map.notified().await;
462
+ } else {
463
+ break;
464
+ }
465
+ }
445
466
  self.workflows.borrow_mut().insert(
446
467
  run_id.clone(),
447
468
  WorkflowData {
@@ -474,7 +495,8 @@ impl WorkflowHalf {
474
495
  return Ok(None);
475
496
  }
476
497
 
477
- // In all other cases, we want to panic as the runtime could be in an inconsistent state at this point.
498
+ // In all other cases, we want to error as the runtime could be in an inconsistent state
499
+ // at this point.
478
500
  bail!(
479
501
  "Got activation {:?} for unknown workflow {}",
480
502
  activation,
@@ -719,7 +741,7 @@ impl Unblockable for NexusStartResult {
719
741
  unblock_dat: od,
720
742
  })
721
743
  }
722
- resolve_nexus_operation_start::Status::CancelledBeforeStart(f) => Err(f),
744
+ resolve_nexus_operation_start::Status::Failed(f) => Err(f),
723
745
  },
724
746
  _ => panic!("Invalid unblock event for nexus operation"),
725
747
  }
@@ -177,7 +177,7 @@ impl WorkflowFuture {
177
177
  &mut self,
178
178
  variant: Option<Variant>,
179
179
  outgoing_cmds: &mut Vec<WorkflowCommand>,
180
- ) -> Result<bool, Error> {
180
+ ) -> Result<(), Error> {
181
181
  if let Some(v) = variant {
182
182
  match v {
183
183
  Variant::InitializeWorkflow(_) => {
@@ -326,17 +326,14 @@ impl WorkflowFuture {
326
326
  ))?
327
327
  }
328
328
  Variant::RemoveFromCache(_) => {
329
- // TODO: Need to abort any user-spawned tasks, etc. See also cancel WF.
330
- // How best to do this in executor agnostic way? Is that possible?
331
- // -- tokio JoinSet does this in a nice way.
332
- return Ok(true);
329
+ unreachable!("Cache removal should happen higher up");
333
330
  }
334
331
  }
335
332
  } else {
336
333
  bail!("Empty activation job variant");
337
334
  }
338
335
 
339
- Ok(false)
336
+ Ok(())
340
337
  }
341
338
  }
342
339
 
@@ -370,8 +367,8 @@ impl Future for WorkflowFuture {
370
367
  .map(Into::into);
371
368
  }
372
369
 
373
- let mut die_of_eviction_when_done = false;
374
370
  let mut activation_cmds = vec![];
371
+ let mut init_activation_cmds = vec![];
375
372
  // Lame hack to avoid hitting "unregistered" update handlers in a situation where
376
373
  // the history has no commands until an update is accepted. Will go away w/ SDK redesign
377
374
  if activation
@@ -386,24 +383,11 @@ impl Future for WorkflowFuture {
386
383
  })
387
384
  {
388
385
  // Poll the workflow future once to get things registered
389
- if self.poll_wf_future(cx, &run_id, &mut activation_cmds)? {
386
+ if self.poll_wf_future(cx, &run_id, &mut init_activation_cmds)? {
390
387
  continue;
391
388
  }
392
389
  }
393
390
 
394
- for WorkflowActivationJob { variant } in activation.jobs {
395
- match self.handle_job(variant, &mut activation_cmds) {
396
- Ok(true) => {
397
- die_of_eviction_when_done = true;
398
- }
399
- Err(e) => {
400
- self.fail_wft(run_id, e);
401
- continue 'activations;
402
- }
403
- _ => (),
404
- }
405
- }
406
-
407
391
  if is_only_eviction {
408
392
  // No need to do anything with the workflow code in this case
409
393
  self.outgoing_completions
@@ -412,6 +396,13 @@ impl Future for WorkflowFuture {
412
396
  return Ok(WfExitValue::Evicted).into();
413
397
  }
414
398
 
399
+ for WorkflowActivationJob { variant } in activation.jobs {
400
+ if let Err(e) = self.handle_job(variant, &mut activation_cmds) {
401
+ self.fail_wft(run_id, e);
402
+ continue 'activations;
403
+ }
404
+ }
405
+
415
406
  // Drive update functions
416
407
  self.update_futures = std::mem::take(&mut self.update_futures)
417
408
  .into_iter()
@@ -438,6 +429,12 @@ impl Future for WorkflowFuture {
438
429
  )
439
430
  .collect();
440
431
 
432
+ // The commands from the initial activation should go _after_ the updates run. This
433
+ // is still a bit of hacky nonsense, as the first poll of the WF future should be able
434
+ // to observe any state changed by the update handlers - but that's impossible to do
435
+ // with current handler registration. In the real SDK, this will be obviated by them
436
+ // being functions on a struct.
437
+ activation_cmds.extend(init_activation_cmds);
441
438
  if self.poll_wf_future(cx, &run_id, &mut activation_cmds)? {
442
439
  continue;
443
440
  }
@@ -450,10 +447,6 @@ impl Future for WorkflowFuture {
450
447
 
451
448
  self.send_completion(run_id, activation_cmds);
452
449
 
453
- if die_of_eviction_when_done {
454
- return Ok(WfExitValue::Evicted).into();
455
- }
456
-
457
450
  // We don't actually return here, since we could be queried after finishing executing,
458
451
  // and it allows us to rely on evictions for death and cache management
459
452
  }
@@ -6,6 +6,10 @@ This repository contains both the protobuf descriptors and OpenAPI documentation
6
6
 
7
7
  Install as git submodule to the project.
8
8
 
9
+ ## Contribution
10
+
11
+ Make your change to the temporal/proto files, and run `make` to update the openapi definitions.
12
+
9
13
  ## License
10
14
 
11
15
  MIT License, please see [LICENSE](LICENSE) for details.
@@ -13,8 +13,6 @@ breaking:
13
13
  - WIRE_JSON
14
14
  ignore:
15
15
  - google
16
- # TODO (yuri) remove this
17
- - temporal/api/workflow/v1/message.proto
18
16
  lint:
19
17
  use:
20
18
  - DEFAULT