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
{{ message }}
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.
Consider the following example, a simple server that when sent a number
replies by sending the sum of all numbers it has been sent so far (asynchronously,
say on a message bus).
dataActionv::*->*whereAdd::Int->Actionv()Sum::ActionvIntModel=Int
next m (Add i) = m + i
next m Sum= m
post m (Add i) _ =True
post m Sum i = i == m
So far so good, but what is the semantics for Sum?
sem (Add i) = apiCallToEndpoint i server
sem Sum=?
It doesn't really make sense, the Sum action is created by the
environment (message bus).
Here's an idea, don't generate Sum actions. Instead let the user
provide a function:
environmentEvents::TChanHistory->IO()
That has access to the history channel, and can listen to the bus and
add Sum events. It's important that the user adds a InvocationEvent
for Sum immediately after it sees a ResponseEvent for Add on the
channel -- otherwise linearisation might fail, e.g.:
|--- Add 1 ---| |--- Add 2 ---|
|-- Sum 1 --|
The ResponseEvent for Sum should be added when the actual message
appears on the message bus.
One clear downside of this approach is that it exposes an implementation
detail, the history channel, to the user. I'm also not sure what to do
about pids (we can't/shouldn't have multiple pending invocations on the
same pid -- that would break sequentiality of the thread).
The text was updated successfully, but these errors were encountered:
Work in progress.
Consider the following example, a simple server that when sent a number
replies by sending the sum of all numbers it has been sent so far (asynchronously,
say on a message bus).
So far so good, but what is the semantics for
Sum
?It doesn't really make sense, the
Sum
action is created by theenvironment (message bus).
Here's an idea, don't generate
Sum
actions. Instead let the userprovide a function:
That has access to the history channel, and can listen to the bus and
add
Sum
events. It's important that the user adds aInvocationEvent
for
Sum
immediately after it sees aResponseEvent
forAdd
on thechannel -- otherwise linearisation might fail, e.g.:
The
ResponseEvent
forSum
should be added when the actual messageappears on the message bus.
One clear downside of this approach is that it exposes an implementation
detail, the history channel, to the user. I'm also not sure what to do
about pids (we can't/shouldn't have multiple pending invocations on the
same pid -- that would break sequentiality of the thread).
The text was updated successfully, but these errors were encountered: