# 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](https://github.com/getclump/clump): service composition
  * [fetch](http://47deg.github.io/fetch/): service composition (we'll expand on this one)
  * [finch](https://github.com/finagle/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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devon-miller.gitbook.io/my-dispatch-user-notes/program_architecture.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
