Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/monzo/typhon
A wrapper around Go's net/http to provide safety and convenience. At Monzo, Typhon forms the basis of most clients and servers in our microservices platform.
https://github.com/monzo/typhon
go golang http microservices rpc
Last synced: 1 day ago
JSON representation
A wrapper around Go's net/http to provide safety and convenience. At Monzo, Typhon forms the basis of most clients and servers in our microservices platform.
- Host: GitHub
- URL: https://github.com/monzo/typhon
- Owner: monzo
- License: mit
- Created: 2015-02-12T10:21:42.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-10-17T08:49:13.000Z (about 2 months ago)
- Last Synced: 2024-12-04T21:07:49.011Z (9 days ago)
- Topics: go, golang, http, microservices, rpc
- Language: Go
- Homepage:
- Size: 4.3 MB
- Stars: 754
- Watchers: 114
- Forks: 56
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-golang-repositories - typhon
README
# Typhon 🐲
[![Build Status](https://travis-ci.org/monzo/typhon.svg?branch=master)](https://travis-ci.org/monzo/typhon)
[![GoDoc](https://godoc.org/github.com/monzo/typhon?status.svg)](https://godoc.org/github.com/monzo/typhon)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][platform blog post].
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 `Service`s; 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.[`net/http`]: https://golang.org/pkg/net/http/
[platform blog post]: https://monzo.com/blog/2016/09/19/building-a-modern-bank-backend/
[`monzo/terrors`]: http://github.com/monzo/terrors
[`h2c`]: https://httpwg.org/specs/rfc7540.html#discover-http