https://github.com/amirhnajafiz/strago
Simple traffic controller agent with Golang.
https://github.com/amirhnajafiz/strago
go golang golang-package load-balancer metrics service-control traffic-control
Last synced: 3 months ago
JSON representation
Simple traffic controller agent with Golang.
- Host: GitHub
- URL: https://github.com/amirhnajafiz/strago
- Owner: amirhnajafiz
- Created: 2022-09-05T07:01:31.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-07-29T05:18:04.000Z (about 2 years ago)
- Last Synced: 2024-06-20T22:33:10.987Z (over 1 year ago)
- Topics: go, golang, golang-package, load-balancer, metrics, service-control, traffic-control
- Language: Go
- Homepage:
- Size: 8.67 MB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
Strago
![]()
![]()
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:
```shell
go get -u github.com/amirhnajafiz/strago
```### build
Then build the executable file:
```shell
go build -o strago
chmod +x ./strago
STRAGO_PORT=9370 STRAGO_SERVICES='127.0.0.1:5050&127.0.0.1:5051' STRAGO_DEBUG=true ./strago
```### docker
Start strago on docker with:
```shell
docker pull amirhossein21/strago:v0.1.1
docker run -d \
-e STRAGO_PORT=9370 \
-e STRAGO_SERVICES='127.0.0.1:5050&127.0.0.1:5051' \
amirhossein21/strago:v0.1.1
```## 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:### test
You can test the above code by creating two _echo servers_:
```shell
### 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:
```shell
curl localhost:9370
```## Envs
- ```STRAGO_SERVICES```: seperated with ```&```. Example: ```127.0.0.1:5050&127.0.0.1:5051```
- ```STRAGO_PORT```: http port
- ```STRAGO_SECURE```: using https or not (ture/false)
- ```STRAGO_TYPE```: load balancing type (0 is request count / 1 is burst time)
- ```STRAGO_DEBUG```: used for debug mode (true/false)## Metrics & Health
Strago metrics will be exposed on ```localhost:9370/metrics```. And you can check the system
health on ```localhost:9370/health```.