Fixed a few issues:

- Incorrect name being shown on dashboard "Proxies page"
- Apps being shown when homepage.show is false
- Load balanced routes are shown on homepage instead of the load balancer
- Route with idlewatcher will now be removed on container destroy
- Idlewatcher panic
- Performance improvement
- Idlewatcher infinitely loading
- Reload stucked / not working properly
- Streams stuck on shutdown / reload
- etc...
Added:
- support idlewatcher for loadbalanced routes
- partial implementation for stream type idlewatcher
Issues:
- graceful shutdown
This commit is contained in:
yusing
2024-10-18 16:47:01 +08:00
parent c0c61709ca
commit 53557e38b6
69 changed files with 2368 additions and 1654 deletions

View File

@@ -4,8 +4,8 @@ import (
"github.com/yusing/go-proxy/internal/docker"
E "github.com/yusing/go-proxy/internal/error"
url "github.com/yusing/go-proxy/internal/net/types"
P "github.com/yusing/go-proxy/internal/proxy"
"github.com/yusing/go-proxy/internal/types"
"github.com/yusing/go-proxy/internal/proxy/entry"
"github.com/yusing/go-proxy/internal/task"
U "github.com/yusing/go-proxy/internal/utils"
F "github.com/yusing/go-proxy/internal/utils/functional"
)
@@ -16,16 +16,16 @@ type (
_ U.NoCopy
impl
Type RouteType
Entry *types.RawEntry
Entry *entry.RawEntry
}
Routes = F.Map[string, *Route]
impl interface {
Start() E.NestedError
Stop() E.NestedError
Started() bool
entry.Entry
task.TaskStarter
task.TaskFinisher
String() string
URL() url.URL
TargetURL() url.URL
}
)
@@ -44,8 +44,8 @@ func (rt *Route) Container() *docker.Container {
return rt.Entry.Container
}
func NewRoute(en *types.RawEntry) (*Route, E.NestedError) {
entry, err := P.ValidateEntry(en)
func NewRoute(raw *entry.RawEntry) (*Route, E.NestedError) {
en, err := entry.ValidateEntry(raw)
if err != nil {
return nil, err
}
@@ -53,11 +53,11 @@ func NewRoute(en *types.RawEntry) (*Route, E.NestedError) {
var t RouteType
var rt impl
switch e := entry.(type) {
case *P.StreamEntry:
switch e := en.(type) {
case *entry.StreamEntry:
t = RouteTypeStream
rt, err = NewStreamRoute(e)
case *P.ReverseProxyEntry:
case *entry.ReverseProxyEntry:
t = RouteTypeReverseProxy
rt, err = NewHTTPRoute(e)
default:
@@ -69,19 +69,21 @@ func NewRoute(en *types.RawEntry) (*Route, E.NestedError) {
return &Route{
impl: rt,
Type: t,
Entry: en,
Entry: raw,
}, nil
}
func FromEntries(entries types.RawEntries) (Routes, E.NestedError) {
func FromEntries(entries entry.RawEntries) (Routes, E.NestedError) {
b := E.NewBuilder("errors in routes")
routes := NewRoutes()
entries.RangeAll(func(alias string, entry *types.RawEntry) {
entry.Alias = alias
r, err := NewRoute(entry)
entries.RangeAllParallel(func(alias string, en *entry.RawEntry) {
en.Alias = alias
r, err := NewRoute(en)
if err != nil {
b.Add(err.Subject(alias))
} else if entry.ShouldNotServe(r) {
return
} else {
routes.Store(alias, r)
}