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
The async arrow type can have many interpretations and is particularly well suited at representing an async request-reply protocol. Data driven services are usually a composition of various request-reply interactions and it can be useful to reify the type.
The supported operations would be all those of arrows as seen here but also many others specific to Async and other types. Consider operations such as:
/// Invokes arrow g and then invokes f if successful (Choice1Of2).valtryBefore(g:AsyncArrow<'a,Choice<'a, 'c>>)(f:AsyncArrow<'a,'b>):AsyncArrow<'a,Choice<'b, 'c>>/// Creates an arrow which propagates its input into the output.valstrength(f:AsyncArrow<'a,'b>):AsyncArrow<'a,'a*'b>/// Creates an arrow which filters inputs to the specified arrow.valfilterAsync(p:AsyncArrow<'a,bool>)(df:Async<'b>)(f:AsyncArrow<'a,'b>):AsyncArrow<'a,'b>
Async filters represent mappings between arrows. A filter can be use to inject various cross-cutting concerns. For example, a timing filter:
lettiming(log:NLog.Logger):AsyncFilter<_,_,_,_>=fun(f:AsyncArrow<'a, 'b>)a->async{letsw= System.Diagnostics.Stopwatch.StartNew()let!res= f a
sw.Stop()
log.Trace("Time Elapsed={0}", sw.ElapsedMilliseconds)return res
}
A filter can also change the input/output type of an arrow. This can be used for layering a JSON codec onto a request/reply protocol, for instance.
typeAsyncSink<'a>= AsyncArrow<'a, unit>
A sink can be used to represent functions which are run solely for the side-effects. An example operation:
letmergeAllPar(ss:seq<AsyncSink<'a>>):AsyncSink<'a>=fun a -> ss |> Seq.map ((|>) a)|> Async.Parallel |> Async.Ignore
The text was updated successfully, but these errors were encountered:
The paper Your Server as a Function explains the applications of these ideas to servers. The difference is mostly in the naming AsyncArrow is Service and AsyncFilter is Filter. Furthermore, they use Future abstraction which is similar to Async in terms of the operations it supports, but inherently different in that it is a promise (more like a TPL Task).
The types:
The async arrow type can have many interpretations and is particularly well suited at representing an async request-reply protocol. Data driven services are usually a composition of various request-reply interactions and it can be useful to reify the type.
The supported operations would be all those of arrows as seen here but also many others specific to
Async
and other types. Consider operations such as:Async filters represent mappings between arrows. A filter can be use to inject various cross-cutting concerns. For example, a timing filter:
A filter can also change the input/output type of an arrow. This can be used for layering a JSON codec onto a request/reply protocol, for instance.
A sink can be used to represent functions which are run solely for the side-effects. An example operation:
The text was updated successfully, but these errors were encountered: