https://github.com/shardulnalegave/freighter
A simple but extensible load balancer written in Go-lang
https://github.com/shardulnalegave/freighter
golang load-balancer
Last synced: 2 months ago
JSON representation
A simple but extensible load balancer written in Go-lang
- Host: GitHub
- URL: https://github.com/shardulnalegave/freighter
- Owner: ShardulNalegave
- License: mit
- Created: 2024-01-18T17:45:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-23T18:01:31.000Z (over 1 year ago)
- Last Synced: 2025-04-11T05:14:27.950Z (2 months ago)
- Topics: golang, load-balancer
- Language: Go
- Homepage: https://shardulnalegave.github.io/freighter/
- Size: 73.2 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Freighter
Simple Load-Balancer written in Go-lang.Freighter is not a pre-built binary/CLI-application, instead it is a Go library which you can add to your own binary.
This allows you to very easily extend its functionality and maybe even add new features which you require. Also, this helps avoid unnecessarily complicated configuration files.**Documentation:** https://shardulnalegave.github.io/freighter
```go
package mainimport (
"net/url"
"time""github.com/ShardulNalegave/freighter"
"github.com/ShardulNalegave/freighter/pool"
"github.com/ShardulNalegave/freighter/strategy"
)func main() {
srv := freighter.NewFreighter(&freighter.Options{
URL: &url.URL{
Host: ":5000",
},
EnableConsoleLogging: true,
HealthCheckInterval: time.Second * 5,
Strategy: &strategy.RoundRobin{},
Backends: []*pool.Backend{
pool.NewBackend(&url.URL{Host: ":8080", Scheme: "http"}, nil),
pool.NewBackend(&url.URL{Host: ":8081", Scheme: "http"}, nil),
},
})srv.ListenAndServe()
}
```