MyNixOS website logo
Description

Generate HTTP2 clients from Servant API descriptions.

servant-http2-client

This package provides a way to generate HTTP2 client code from Servant API descriptions.

Please consider this package somewhat unstable. The author would appreciate feedbacks and benchmarks in real-world deployments.

Usage

The usage is pretty similar to servant-client but uses an HTTP2Client rather than a Manager. See also the section below to highlight differences between servant-client and servant-http2-client.

HTTP2 uses a flow-control mechanism, which http2-client exposes but servant-http2-client hides: as a client you have nothing to do and DATA-credit is immediately sent to the server. This mechanism is easy for the user but effectively disables flow control at the application level. Further, this easy-to-use mechanism may have some slight overhead for sending many small control frames. Future version of the library will expose more control points (at an increased cost).

You can find a full example at ./test/Spec.hs .

Differences with servant-client

The client leverages http2-client and hence behave slightly differently from servant-client, which uses http-client. Most notably, HTTP/2 uses a single TCP connection for performing concurrent requests, whereas HTTP/1.x at best pipelines request sequentially over a same connection.

The servant-client library uses a connection Manager to create new TCP connections or try re-using existing connections. This servant-http2-client makes no use of such a Manager. This difference is mostly important for load-balancing and unstable network environments. When targeting a load-balanced server, a servant-http2-client will always hit the same TCP-endpoint whereas a servant-client may hit different TCP-endpoint for each request. Also, after handling a connection error, a servant-client will open a new TCP connection without any decision from the programmer. Conversely, a broken servant-http2-client will be of no practical use and the programmer must create a new H2ClientEnv. A Manager abstraction may be added to http2-client later.

The servant-client package offers Cookies handling, whereas servant-http2-client has no such feature. Please consider opening a pull-request for adding the support.

Finally, it's always good to remember that HTTP2 allows concurrent queries, that is, many API calls may fail when a single TCP connection dies out.

Metadata

Version

0.1.0.2

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows