A thin wrapper around Go's net/http to provide safety and convenience. At Monzo, Typhon is responsible for RPC clients and servers and forms the basis of most of our services.
Branch: master
Clone or download
EddShaw Merge pull request #112 from monzo/edshaw-error-rsp-correlate-req
Typhon: Set response Request when routing
Latest commit 0e904ef Jan 10, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Replace Router internals ⚡️ Dec 30, 2018
vendor Remove venedored labstack/echo and dependencies 🗑 Dec 30, 2018
.editorconfig Fix up README file Mar 7, 2018
.gitignore add some tests Feb 24, 2015
.travis.yml
Gopkg.lock Remove venedored labstack/echo and dependencies 🗑 Dec 30, 2018
Gopkg.toml Remove venedored labstack/echo and dependencies 🗑 Dec 30, 2018
LICENCE Update year in LICENSE file 🎇 Nov 15, 2018
README.md Minor updates to documentation Dec 3, 2018
buffer.go Improved godocs Dec 20, 2018
chunk.go Pool buffers used to copy response bodies 🏊‍♂️ Nov 16, 2018
client.go Improved godocs Dec 20, 2018
doc.go Improved godocs Dec 20, 2018
e2e_bench_test.go Move benchmarks to their own test files 🏡 Nov 16, 2018
e2e_http1_test.go Connection draining for h2c connections 🚽 Nov 16, 2018
e2e_http2_test.go Connection draining for h2c connections 🚽 Nov 16, 2018
e2e_test.go Test for HTTP/2.0 full-duplex communication Dec 20, 2018
errors.go Improved godocs Dec 20, 2018
expire.go Remove TimeoutFilter Apr 22, 2017
expire_test.go Slightly beefier test for ExpirationFilter Sep 13, 2018
filter.go Improved godocs Dec 20, 2018
h2c.go Minor updates to documentation Dec 3, 2018
http.go Improved godocs Dec 20, 2018
http_darwin.go More nuanced logging for response body copying errors Oct 25, 2018
http_linux.go More nuanced logging for response body copying errors Oct 25, 2018
http_other.go More nuanced logging for response body copying errors Oct 25, 2018
request.go Document that Request/Response don't guarantee safe concurrent access 💬 Dec 30, 2018
request_test.go Allow an io.Reader to be passed to Encode() methods Dec 20, 2018
response.go
response_bench_test.go Move benchmarks to their own test files 🏡 Nov 16, 2018
response_test.go Allow an io.Reader to be passed to Encode() methods Dec 20, 2018
response_writer.go Thread http.Hijacker through to Response.Writer() 🧚‍♂️ Nov 15, 2018
router.go
router_bench_test.go
router_test.go Typhon: Set response Request when routing Jan 10, 2019
server.go Remove HttpServer Dec 20, 2018
service.go Fix typo Aug 6, 2018
util_test.go Add TLS flavours of tests 🔐 Nov 16, 2018

README.md

Typhon 🐲

Build Status GoDoc

Typhon is a wrapper around Go's net/http library that we use at Monzo to build RPC servers and clients in our microservices platform.

It provides a number of conveniences and tries to promote safety wherever possible. Here's a short list of interesting features in Typhon:

  • No need to close body.Close() in clients
    Forgetting to body.Close() in a client when the body has been dealt with is a common source of resource leaks in Go programs in our experience. Typhon ensures that – unless you're doing something really weird with the body – it will be closed automatically.

  • Middleware "filters"
    Filters are decorators around Services; in Typhon servers and clients share common functionality by composing it functionally.

  • Body encoding and decoding
    Marshalling and unmarshalling request bodies to structs is such a common operation that our Request and Response objects support them directly. If the operations fail, the errors are propagated automatically since that's nearly always what a server will want.

  • Propagation of cancellation
    When a server has done handling a request, the request's context is automatically cancelled, and these cancellations are propagated through the distributed call stack. This lets downstream servers conserve work producing responses that are no longer needed.

  • Error propagation
    Responses have an inbuilt Error attribute, and serialisation/deserialisation of these errors into HTTP errors is taken care of automatically. We recommend using this in conjunction with monzo/terrors.

  • Full HTTP/1.1 and HTTP/2.0 support
    Applications implemented using Typhon can communicate over HTTP/1.1 or HTTP/2.0. Typhon has support for full duplex communication under HTTP/2.0, and h2c (HTTP/2.0 over TCP, ie. without TLS) is also supported if required.