Indexed by TopGit from live GitHub metadata: ripienaar/nats-roundtripper has 84 stars, written primarily in Go.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
This is a Golang http.RoundTripper that uses NATS as a transport.
Included is a http.RoundTripper for clients, a server that uses normal HTTP Handlers and any existing http handler mux and a Caddy Server transport.
Why?
Using NATS as a transport for microservices has a number of advantages, you get a lot
of the benefits of a service mesh with no additional infrastructure.
Load balancing is free with no additional components like load balancers
Failover is free with no additional components like load balancers
Geo failover and fallback is free with no additional components like global dns
Long running connections are used for microservices speeding up connection handling
NATS support canary deploys, gradual deploys, traffic shaping or more
NATS, being subject and interest based, does not need any additional infrastructure for service discovery
Moving to NATS as transport for microservices can be a big job, implementing a
http.RoundTripper means your existing microservices can be hosted on nats with
minimal changes.
You can see it in action on YouTube doing geo failover.
Example?
Server / Microservice
See the Weather Service
The server is a normal HTTP server, no changes to your handlers:
http.HandleFunc("/city", cityHandler)
// allow for gradual migration by listening on HTTP
log.Printf("Listening on 8080")
go http.ListenAndServe(":"+port, nil)
// Listen on NATS
nats, _ := nrt.New(nrt.WithNatsServer("nats.internal"))
go nats.ListenAndServ(context.Background(), "weather.nats", nil)
<-context.Background().Done()
Client
The client is a normal HTTP client, see the bundled nrtget
I have a Caddy Server 2 extension that you can build using xcaddy, using this you can bridge
existing HTTP traffic to a backend managed by NATS.
This extension is just an experiment, the Caddy 2 documentation is non existent so doing the right thing is quite hard. Caddy is really
attractive though as it's high speed, easy to extend and support many features like Lets Encrypt right out of the box.
You'd look to use something like this to bridge existing traffic to your backend, or to assist with migrating from a current REST based solution to a NATS one.
{
order nats last
}
http://:9090 {
nats /city weather.nats
}
Run this using the environment variables listed below like NATS_CONTEXT for configuration.
With this in place requests to http://example.net:9090/city will be sent to the NATS backend weather.nats microservice.
This has a number of advantages:
A long-running connection from Caddy to NATS is made significantly reducing the cost overhead of connection management, especially with TLS
Despite being a single long running connection load balancing and geo failover is supported
The connection is self managing and will reconnect automatically, supports NATS topology discovery and will keep working through scale ups and downs of the NATS infrastructure
Massive infrastructure reduction as you don't need any service discovery or LB level configuration to do traffic shaping etc
Traffic Management
Load balancing
Without any additional effort the service will scale horizontally and vertically, simply starting more of the same code will cause the load to be randomly distributed.
Geo Failover
If instances of the service is started in multiple NATS Clustered connected into a Super Cluster then connections made in cluster "east" will automatically failover to cluster "west" and fall back to "east" when workers are available.
Canary Deploys
When running a service the NATS_PREFIX environment variable or the WithPrefix() option can adjust the subjects where the service listen.
Lets assume we have both a v1 and v2 running, and we wish to test 10% of the traffic against v2. Configuring the NATS Server as follows will set this up:
With this in place 10% of the traffic will be routed to v2 of the microservice. These settings can be adjusted on the fly to migrate traffic onto v2 gradually.
Fault Injection
Building on the mappings above we can arrange for 10% of the traffic to be lost:
Here we ensure no services listens on v1.discard... and those 10% of traffic will be lost.
Design?
A server like weather.nats will subscribe in a queue group to the subject nrt.requests.weather.nats.*, clients
will publish a GET request to nrt.requests.weather.nats.get.
The body being sent is the entire HTTP request, exactly as it came in the wire. On the server this is received and
turned into a standard http.Request and sent to the handler.
Response is simply a response containing the entire body with some headers added:
Header
Meaning
NRT-ID
A unique request ID set by the server
NRT-Connected-Server
The NATS server the microservice was connected to
NRT-Client
The Client ID of the server connection
NRT-Connected-Cluster
The cluster the server is connected to if clustered
Configuration ?
Several environment variables influence the behavior of the transport, most have matching options to configure the connections:
Variable
Description
NATS_CONTEXT
A context to use as made by the nats context save command, see NATS_ENV
NATS_ENV
Set to true when no nats context is used, configure using the NATS_* variables instead
NATS_URL
Where the nats servers are
NATS_USER
User to connect as, also used as token when password is empty
NATS_PASSWORD
The password to connect with
NATS_CREDS
Path to a nats creds file
NATS_NKEY
NKey to authenticate with
NATS_CERT
Path to a x509 certificate
NATS_KEY
Path to a x509 private key
NATS_CA
Path to a x509 certificate authority certificate chain
NATS_PREFIX
A subject to prefix to the hostname, defaults to nrt
Does ripienaar/nats-roundtripper have a project website?
No homepage URL was recorded for ripienaar/nats-roundtripper in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
Does ripienaar/nats-roundtripper have any tags?
TopGit's last sync did not record any GitHub topics for ripienaar/nats-roundtripper. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on ripienaar/nats-roundtripper?
The most recent commit recorded on ripienaar/nats-roundtripper was 5.5 years ago, based on the GitHub push timestamp. The repository has 3 forks — one of the better signals of community interest.
How many stars does ripienaar/nats-roundtripper have?
ripienaar/nats-roundtripper has 84 GitHub stars — refresh the page for the live number, or check github.com/ripienaar/nats-roundtripper. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is ripienaar/nats-roundtripper open source?
Yes — ripienaar/nats-roundtripper ships under the Apache-2.0 license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/ripienaar/nats-roundtripper.
Where do I read more about ripienaar/nats-roundtripper?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/ripienaar/nats-roundtripper is the definitive source.
Read full README in the tab above.
Curious whether nats-roundtripper is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about nats-roundtripper.