realbucksavage / stargate

A lightweight and extensible library to build gateway servers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go Reference codecov Report Card

Stargate

A minimal and extensible library to build gateway servers. Stargate aims to be simple while providing niche solutions like several load balancer implementations, middleware, service discovery, etc.

Stargate supports:

  • WebSockets
  • Hot-reloading of routes
  • Middleware

stargatecontrb contains some middleware implementations that are not in the scope of this library, but might be useful for some people.

Getting started

Check the basic example that implements a stargate.ServiceLister to create a static table of routes and uses round-robin approach to load balance the request.

In the same sprits, the WebSockets example shows a simple WebSocket backend.

Customize logging

Stargate uses stargate.Log variable to write its logging output. This variable is an implementation of stargate.Logger. You may write your own implementation of this interface and write stargate.Log = myOwnLogger{} whenever your program starts.

Check the custom logger example.

Using dynamic route tables.

If the stargate.ServiceLister's implementation updates the route table, the stargate.Router instance can be told to update the routing by calling the Reload() method.

Check the reloading routes example.

Eureka service discovery

Check the eureka package in stargatecontrib.

Middleware

Stargate defines middleware as:

type MiddlewareFunc func (http.Handler) http.Handler

Check the middleware example, that counts the number of requests served.

Open TODOs

  • Improve logging
  • Improve documentation
  • Write more tests
  • Customizable healthchecks

LoadBalancer implementations

  • Priority round-robin

About

A lightweight and extensible library to build gateway servers.

License:MIT License


Languages

Language:Go 100.0%