Go to content

The Async Arrow - Troy Kershaw

We call services a lot. We have to deal with authorisation, data transformation, logging, retries, error handling and more. To make this simpler we often wrap this logic in a function that takes a Request and returns an asynchronous Response. If you have, congratulations: you've already implemented an async arrow. Arrows are simple to define, yet their application is incredibly powerful. By always providing access to the Request and Response values, arrows allow us to remove the logging, retries, etc. from within our function and compose them instead.In this talk we'll discuss async in F# and use it to create an async arrow that calls a service. We'll then create functions that show how arrows greatly simplify this common task. By the end we will have used our arrow to: Call a service Handle the response Log the request and the response Add an authorisation token to the request Retry with exponential backoff Handle errorsand we'll do all of this using composition and without needing to run our async expression.

January 16, 2017