Program Architecture

Each program that access http resources will be different. Some programs may use a few http client's, one or many depending on its architecture.

Generally, if there are just a few calls to a http server and the protocol is not complex, e.g. no SSL or filtering needed on every packet, the default http client is often sufficient.

But if you have any complexity to your program, you will probably need to configure your http client explicitly and use more than one client. You will also need to worry about service compositon and error handling.

This chapter includes notes on:

  • dispatch Http clients

  • Service compositon:

    • clump: service composition

    • fetch: service composition (we'll expand on this one)

    • finch: scala combinators for building finagle services. It's only for finagle programs and finagle has its own http client. finch is mentioned here for completeness.

    • haxl, stitch: various haskell or scala libraries that are not open source or not scala :-)

  • Error handling

    • Managing errors across many service calls

There are other libraries that can help you process results, such as fs2 or monix. Both of these are asynchronous and non-blocking as well. What you use to process results, of course, is application specific. Note that fs2 and monix can also compose request and responses together if your model is based on streaming, data-driven models. Its easy to see that many web programs can be seen as an endless stream of requests, but for the moment we'll stick to service composition via a library like fetch.

Last updated