-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemporal.stub.php
More file actions
123 lines (107 loc) · 4.93 KB
/
Copy pathtemporal.stub.php
File metadata and controls
123 lines (107 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
* @generate-class-entries
*
* Native Temporal transport for PHP TrueAsync, built on the official Temporal
* Rust core (sdk-core-c-bridge).
*
* This extension is intentionally a thin transport: it exposes only the
* connection and an async `rpcCall`. The high-level client API is the reused
* official Temporal PHP SDK (the `Temporal\*` namespace, shipped as a composer
* package) driven through a `ServiceClientInterface` adapter over
* `TrueAsync\Temporal\Core\Connection`.
*/
namespace TrueAsync\Temporal;
/** Base exception for the native Temporal transport. */
class TemporalException extends \RuntimeException {}
/** Transport / connection failure (connect, broken stream, cancel). */
class ConnectionException extends TemporalException {}
/** Non-OK gRPC status returned by the Temporal frontend service. */
class ServiceException extends TemporalException
{
/**
* The serialized google.rpc.Status (the gRPC `grpc-status-details-bin`
* trailer) carrying typed error details, or null. Used by the SDK to map a
* status into a specific exception.
*/
public ?string $statusDetails = null;
}
namespace TrueAsync\Temporal\Core;
/**
* Low-level transport over the Temporal Rust core. Each call parks the current
* coroutine while the core runs the gRPC on its own threads, then resumes it
* through a cross-thread trigger. Called outside a coroutine (the top-level
* flow), it launches the scheduler and runs as the main coroutine — no explicit
* Async\spawn() wrapper is required, just like Async\await().
*/
final class Connection
{
public function __construct(
string $address,
?string $identity = null,
?string $apiKey = null,
bool $tls = false,
?string $tlsServerRootCaCert = null,
?string $tlsClientCert = null,
?string $tlsClientPrivateKey = null,
?string $tlsServerName = null,
) {}
/**
* Issue a unary RPC. `$service` selects the gRPC service (1 = Workflow).
* `$metadata` is a map of header name => value (string) or list of values,
* forwarded as gRPC call metadata (e.g. an API key / Authorization header).
* Returns the response protobuf bytes; throws ConnectionException /
* ServiceException on failure.
*/
public function rpcCall(int $service, string $method, string $request, int $timeoutMs = 0, array $metadata = []): string {}
}
/**
* Low-level activity worker over the Temporal Rust core. The Rust core polls the
* server (poll/respond loop) on its own threads; this class hands the polled
* tasks (coresdk protobuf bytes) to PHP and takes back completions. The high-
* level dispatch/execution is the reused SDK; this is only the transport.
*/
final class Worker
{
/**
* `$options` tunes the core worker (defaults in parentheses):
* - workflowSlots (100), localActivitySlots (100), nexusSlots (100) —
* fixed-size task slot suppliers, like maxConcurrentActivities;
* - maxCachedWorkflows (1000) — sticky cache size (a perf knob: replay
* stays correct at any size);
* - stickyScheduleToStartTimeoutMs (10000);
* - gracefulShutdownMs (0) — how long in-flight activities get after
* initiateShutdown() before the core cancels them;
* - activityPollers (5), workflowPollers (2), nexusPollers (1) — poller
* maximums.
*/
public function __construct(Connection $connection, string $taskQueue, string $namespace = 'default', int $maxConcurrentActivities = 100, array $options = []) {}
/**
* Poll for the next activity task. Parks the coroutine until a task is
* ready; returns the serialized coresdk ActivityTask, or null once the
* worker has shut down.
*/
public function pollActivityTask(): ?string {}
/** Report an activity task completion (serialized coresdk completion). */
public function completeActivityTask(string $completion): void {}
/**
* Record an activity heartbeat (serialized coresdk ActivityHeartbeat).
* Synchronous — never parks the coroutine: the core stores the heartbeat in
* memory and throttles/sends it to the server on its own threads. A pending
* cancellation is delivered separately, as a cancel-variant task from
* pollActivityTask().
*/
public function recordActivityHeartbeat(string $heartbeat): void {}
/**
* Poll for the next workflow activation. Parks the coroutine until an
* activation is ready; returns the serialized coresdk WorkflowActivation, or
* null once the worker has shut down.
*/
public function pollWorkflowActivation(): ?string {}
/** Report a workflow activation completion (serialized coresdk completion). */
public function completeWorkflowActivation(string $completion): void {}
/** Begin graceful shutdown; pending and subsequent polls return null. */
public function initiateShutdown(): void {}
/** Wait for shutdown to fully drain. */
public function finalizeShutdown(): void {}
}