mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 20:52:33 +02:00
fixed loadbalanced routes with same alias cause conflict
This commit is contained in:
parent
b296fb2965
commit
8b8e1773e8
4 changed files with 8 additions and 5 deletions
|
@ -17,7 +17,7 @@ var (
|
||||||
ErrOutOfRange = stderrors.New("out of range")
|
ErrOutOfRange = stderrors.New("out of range")
|
||||||
ErrTypeError = stderrors.New("type error")
|
ErrTypeError = stderrors.New("type error")
|
||||||
ErrTypeMismatch = stderrors.New("type mismatch")
|
ErrTypeMismatch = stderrors.New("type mismatch")
|
||||||
ErrPanicRecv = stderrors.New("panic")
|
ErrPanicRecv = stderrors.New("panic recovered from")
|
||||||
)
|
)
|
||||||
|
|
||||||
const fmtSubjectWhat = "%w %v: %q"
|
const fmtSubjectWhat = "%w %v: %q"
|
||||||
|
|
|
@ -124,7 +124,6 @@ func (r *HTTPRoute) Start(providerSubtask task.Task) E.NestedError {
|
||||||
r.handler = waker
|
r.handler = waker
|
||||||
r.HealthMon = waker
|
r.HealthMon = waker
|
||||||
case entry.UseHealthCheck(r):
|
case entry.UseHealthCheck(r):
|
||||||
logrus.Debugf("%s health check: %+v", r.Alias, r.HealthCheck)
|
|
||||||
r.HealthMon = health.NewHTTPHealthMonitor(r.TargetURL(), r.HealthCheck, r.rp.Transport)
|
r.HealthMon = health.NewHTTPHealthMonitor(r.TargetURL(), r.HealthCheck, r.rp.Transport)
|
||||||
}
|
}
|
||||||
r.task = providerSubtask
|
r.task = providerSubtask
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
E "github.com/yusing/go-proxy/internal/error"
|
E "github.com/yusing/go-proxy/internal/error"
|
||||||
|
"github.com/yusing/go-proxy/internal/proxy/entry"
|
||||||
R "github.com/yusing/go-proxy/internal/route"
|
R "github.com/yusing/go-proxy/internal/route"
|
||||||
"github.com/yusing/go-proxy/internal/task"
|
"github.com/yusing/go-proxy/internal/task"
|
||||||
W "github.com/yusing/go-proxy/internal/watcher"
|
W "github.com/yusing/go-proxy/internal/watcher"
|
||||||
|
@ -101,7 +102,10 @@ func (p *Provider) MarshalText() ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) startRoute(parent task.Task, r *R.Route) E.NestedError {
|
func (p *Provider) startRoute(parent task.Task, r *R.Route) E.NestedError {
|
||||||
subtask := parent.Subtask("route %s", r.Entry.Alias)
|
if entry.UseLoadBalance(r) {
|
||||||
|
r.Entry.Alias = p.String() + "/" + r.Entry.Alias
|
||||||
|
}
|
||||||
|
subtask := parent.Subtask(r.Entry.Alias)
|
||||||
err := r.Start(subtask)
|
err := r.Start(subtask)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.routes.Delete(r.Entry.Alias)
|
p.routes.Delete(r.Entry.Alias)
|
||||||
|
|
|
@ -62,7 +62,7 @@ func (e *EventQueue) Start(eventCh <-chan Event, errCh <-chan E.NestedError) {
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
e.onError(E.PanicRecv("panic in onFlush %s", err))
|
e.onError(E.PanicRecv("onFlush: %s", err))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
e.onFlush(flushTask, queue)
|
e.onFlush(flushTask, queue)
|
||||||
|
|
Loading…
Add table
Reference in a new issue