Simple traffic controller agent with Golang.

  • By AmirH.Najafizadeh
  • Last update: Nov 22, 2022
  • Comments: 0

logo

Strago

go version version

Simple traffic controller agent with Golang. With Strago you can create and config a load balancer for your services. Load balancing logic of Strago is very simple, it works by the number of requests per service or the total burst time of requests in each service. All you need to do is to give your service addresses as an IP and leave the rest up to Strago.

How to use?

Install library:

go get -u github.com/amirhnajafiz/strago

Example

If you set two echo servers on localhost ports 5050 and 5051, then you have to set the strago server like the example below:

package main

import "github.com/amirhnajafiz/strago"

func main() {
	// creating a new strago server
	server := strago.NewServer(strago.DefaultOptions())

	// set services
	server.WithServices("127.0.0.1:5050", "127.0.0.1:5051")

	// enable server
	server.Enable()

	// start server
	if err := server.Start(); err != nil {
		panic(err)
	}
}

Test

You can test the above code by creating two echo servers:

### generating a service on port 5050
go run example/echo/main.go 5050
### generating a service on port 5051
go run example/echo/main.go 5051

Now you can test the load-balancer:

curl localhost:9370

Metrics

You can get prometheus metrics from localhost:9370/metrics.

Download

strago.zip