Skip to content

Latest commit

 

History

History
64 lines (40 loc) · 2.29 KB

README.md

File metadata and controls

64 lines (40 loc) · 2.29 KB

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