This commit is contained in:
aozhiwei 2024-08-30 17:11:18 +08:00
parent af5d7a34de
commit ee38f2d2e5
2 changed files with 29 additions and 2 deletions

View File

@ -3,11 +3,13 @@ package service
import (
"f5"
"main/mt"
"main/constant"
"q5"
"sync"
"sync/atomic"
"time"
"math/rand"
"fmt"
)
type downStreamHost struct {
@ -186,7 +188,32 @@ func (this *sApiForward) outputMonitorLog() {
}
func (this *sApiForward) LoadDownStreams() error {
return nil
err, ds := f5.GetGoStyleDb().NewOrmSelect(
constant.CONF_DB,
"t_apigate_host",
[][]string{})
if err == nil {
downStreams := []*downStreamHost{}
q5.NewSlice(&downStreams, 0, 20)
for ds.Next() {
host := ds.GetByName("apigate_host")
port := q5.ToInt32(ds.GetByName("apigate_port"))
enable := q5.ToInt32(ds.GetByName("enable"))
if enable != 0 {
downSteam := *q5.NewSliceElement(&downStreams)
downSteam.host = host
downSteam.port = port
downSteam.url = fmt.Sprintf("http://%s:%d", downSteam.host, downSteam.port)
}
}
if len(downStreams) > 0 {
this.downStreams = downStreams
}
f5.GetSysLog().Info("LoadDownstreams ok %s", q5.EncodeJson(&downStreams))
} else {
f5.GetSysLog().Info("LoadDownstreams err %s", err)
}
return err
}
func (this *sApiForward) GetDownStreamHost() (string, string) {

2
third_party/f5 vendored

@ -1 +1 @@
Subproject commit dc1b9c2f6daf272347eea09fa8baaf15479adc41
Subproject commit cc336fdc0af560cc03b4d0bf6776b00054f5df64