diff --git a/server/gamesapi/service/sapi_forward.go b/server/gamesapi/service/sapi_forward.go index c248cdb2..ce3b02a3 100644 --- a/server/gamesapi/service/sapi_forward.go +++ b/server/gamesapi/service/sapi_forward.go @@ -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) { diff --git a/third_party/f5 b/third_party/f5 index dc1b9c2f..cc336fdc 160000 --- a/third_party/f5 +++ b/third_party/f5 @@ -1 +1 @@ -Subproject commit dc1b9c2f6daf272347eea09fa8baaf15479adc41 +Subproject commit cc336fdc0af560cc03b4d0bf6776b00054f5df64