initial commit

This commit is contained in:
Zoe
2025-05-15 15:41:10 +00:00
commit 2e7e6586ca
5 changed files with 268 additions and 0 deletions

65
README.md Normal file
View File

@@ -0,0 +1,65 @@
# Sentinel
Sentinel is a highly-available reverse proxy that can be used to distribute traffic to multiple backends. It is designed to be simple to use and easy to configure.
## Features
- Simple to use
- Easy to configure
- Highly-available
## Installation
To install Sentinel, you can use the following command:
```
go get github.com/juls0730/sentinel
```
## Usage
all you need is a structure that holds the proxyManager structure and a function that returns a transport for the proxyManager
```go
package main
import (
"github.com/juls0730/sentinel"
"net/http"
)
func main() {
proxyManager := sentinel.NewProxyManager()
proxyManager.ListenAndServe("localhost:8080")
proxy, err := NewDeploymentProxy(socketPath)
if err != nil {
return err
}
proxyManager.AddProxy("text.local", proxy)
}
type unixDialer struct {
socketPath string
}
// dialContext implements DialContext but ignored everthing and just gives you a connection to the unix socket
func (d *unixDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
return net.Dial("unix", d.socketPath)
}
func getTransport(target string) *http.Transport {
return &http.Transport{
DialContext: (&unixDialer{socketPath: socket}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
MaxIdleConnsPerHost: 100,
ForceAttemptHTTP2: false,
}
}
```
If you want more indepth examples of how to use Sentinel, you can check out [gloom](https://github.com/juls0730/gloom) which is a plugin-based web server that uses Sentinel to distribute traffic to multiple backends, or [Flux](https://github.com/juls0730/flux) which is a mini-paas that uses Sentinel to distribute traffic to project containers.