Distributed Coordination Protocol
The Distributed Coordination Protocol is responsible for the coordination of distributed function executions.
Eventual Resumption
Eventual resumption occurs when when the calling execution E1 awaits a promise P2 that is not yet resolved. The calling execution E1 is suspended until the promise P2 is resolved or rejected.
-
When the calling execution E1, identified by Durable Promise P1 and hosted on worker W1, invokes a function remotely, W1 sends a request to create a Durable Promise (P2) to the server S.
-
Upon receiving the request, the server S creates the durable promise P2.
-
The Server S sends a response to W1 which forwards P2 to E1.
-
The server S sends an Invoke(P2) message to process group GB, here delivered to worker W2
-
Worker W2 spawns execution E2
-
When the calling execution E1 awaits promise P2, W1 sends a request to register a callback Resume(P1, P2) deliverable to GA with preference W1 on P2 to server S
-
Upon receiving the request, since P2 is still pending, server S registers the callback C1 with promise P2.
-
Server S sends a response indicating success to worker W1, which suspends E1
-
When the called execution E2 returns, the worker W2 sends a request to resolve or reject durable promise P2 to the server S
-
Upon receiving the request, the server S resolves or rejects the durable promise P2.
-
Server S sends a response containing P2 to W2.
12.The server S sends a Resume(P1, P2) message to process group GA with the preference of W1, here delivered to worker W1, which suspends E1.
Immediate Resumption
Immediate resumption occurs when the calling execution E1 awaits a promise P2 that is already resolved.
-
When the calling execution E1, identified by durable promise P1 and hosted on worker W1, invokes a function remotely, W1 sends a request to create a durable promise P2 to the server S.
-
Upon receiving the request, the server S creates the durable promise P2.
-
Server S sends a response to W1, which forwards P2 to E1.
-
The server S sends an Invoke(P2) message to process group GB, here delivered to worker W2.
-
Worker W2 spawns execution E2.
-
When the called execution E2 returns, the worker W2 sends a request to resolve or reject durable promise P2 to the server S.
-
Upon receiving the request, the server S resolves or rejects the durable promise P2.
-
Server S sends a response containing P2 to W2.
-
When the calling execution E1 awaits promise P2, W1 sends a request to register a callback Resume(P1, P2) deliverable to GA with preference W1 on P2 to server S.
-
Upon receiving the request, since P2 is already completed, server S does not register a callback.
-
Server S sends a response indicating the callback was not registered because the promise is already completed to worker W1, which resumes E1.