You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, the choreographies can only accept unicast messages of type Located as arguments. This seems problematic for the colocally operator since then the inner choreography for colocally cannot be passed messages of type Colocated, which doesn't make sense since colocally works with multiple locations at once, so it makes more sense for it to be able to accept Colocated messages sent to multiple locations. Choreographies also cannot return messages of type Colocated at the moment, which again seems problematic for the colocally operator.
For example, the following is currently considered invalid:
typeLocations="alice"|"bob"|"carol"|"dave";constdualResponse: Choreography<Locations,[Colocated<string,"alice"|"bob"|"dave">,Colocated<string,"carol"|"bob"|"dave">],[Colocated<string,"bob"|"alice"|"carol">,Colocated<string,"dave"|"alice"|"carol">]>=async({ locally, peel, multicast },[msgAlice,msgCarol])=>{constaliceMsg=peel(msgAliceasColocated<string,Locations>);constcarolMsg=peel(msgCarolasColocated<string,Locations>);if(aliceMsg.length>0&&carolMsg.length>0){constresponseBob=awaitlocally("bob",()=>"hi, this is bob");constcolocatedBob=awaitmulticast("bob",["alice","carol"],responseBob);constresponseDave=awaitlocally("dave",()=>"hi, this is dave");constcolocatedDave=awaitmulticast("dave",["alice","carol"],responseDave);return[colocatedBob,colocatedDave];}return["",""];};consttest: Choreography<Locations,[],[Colocated<string,"bob"|"alice"|"carol">,Colocated<string,"dave"|"alice"|"carol">]>=async({ locally, multicast, colocally })=>{constmsgAtAlice=awaitlocally("alice",()=>"hi from alice");constcolocatedAlice=awaitmulticast("alice",["bob","dave"],msgAtAlice);constmsgAtCarol=awaitlocally("carol",()=>"hi from carol");constcolocatedCarol=awaitmulticast("carol",["bob","dave"],msgAtCarol);constresponses=awaitcolocally(["bob","dave"],dualResponse,[colocatedAlice,colocatedCarol,]);returnresponses;};
Here, we have the dualResponse choreography accepting two Colocated messages as arguments when it's used with colocally in the test choreography. We also have dualResponse returning two Colocated messages in response. It seems like this should be valid, which is why I'm proposing to amend the Choreography type to allow for choreographies that can accept and return both the Located and Colocated message types. Making this change would also mean that the no-unused-colocated-location ESLint rule would need to be amended to handle this situation.
The text was updated successfully, but these errors were encountered:
ImpregnableProgrammer
changed the title
Choreographies currently only accept Located messages as arguments
Choreographies can currently only accept Located messages as arguments
Aug 15, 2023
At the moment, the choreographies can only accept unicast messages of type
Located
as arguments. This seems problematic for thecolocally
operator since then the inner choreography forcolocally
cannot be passed messages of typeColocated
, which doesn't make sense sincecolocally
works with multiple locations at once, so it makes more sense for it to be able to acceptColocated
messages sent to multiple locations. Choreographies also cannot return messages of typeColocated
at the moment, which again seems problematic for thecolocally
operator.For example, the following is currently considered invalid:
Here, we have the
dualResponse
choreography accepting twoColocated
messages as arguments when it's used withcolocally
in thetest
choreography. We also havedualResponse
returning twoColocated
messages in response. It seems like this should be valid, which is why I'm proposing to amend theChoreography
type to allow for choreographies that can accept and return both theLocated
andColocated
message types. Making this change would also mean that theno-unused-colocated-location
ESLint rule would need to be amended to handle this situation.The text was updated successfully, but these errors were encountered: