更新工具跨服配置

This commit is contained in:
wh_zcy 2023-01-07 17:14:36 +08:00
parent ca2e14fb01
commit c639d6359e
3 changed files with 97 additions and 24 deletions

View File

@ -8,19 +8,22 @@ func newDefaultConfig() *Config {
Concurrency: 10, Concurrency: 10,
DurationS: 5, DurationS: 5,
}, },
UserCount: 100, UserCount: 100,
UpgradeUrl: "http://10.0.0.9:8080/",
} }
} }
type Config struct { type Config struct {
Pressure PressureConfig `json:"Pressure,omitempty"` Pressure PressureConfig `json:"Pressure,omitempty"`
UserCount int32 `json:"UserCount,omitempty"` //用户数 UserCount int32 `json:"UserCount,omitempty"` //用户数
SId string `json:"sid,omitempty"` //区服ID SId string `json:"sid,omitempty"` //区服ID
WsAddr string `json:"wsAddr,omitempty"` //websocket addr WsAddr string `json:"wsAddr,omitempty"` //websocket addr
IntervalS int32 `json:"intervalS,omitempty"` //间隔时间s IntervalS int32 `json:"intervalS,omitempty"` //间隔时间s
LubanConf *LubanConfig `json:"lubanConf,omitempty"` //luban工具配置 LubanConf *LubanConfig `json:"lubanConf,omitempty"` //luban工具配置
PbConf *ProtobufConfig `json:"pbConf,omitempty"` //Pb配置 PbConf *ProtobufConfig `json:"pbConf,omitempty"` //Pb配置
SyncConf *SyncConfig `json:"syncConf,omitempty"` //同步配置 SyncConf *SyncConfig `json:"syncConf,omitempty"` //同步配置
UpgradeUrl string `json:"upgradeUrl,omitempty"` //升级服务
Servers []*ServerConfig `json:"servers,omitempty"` //区服配置
} }
//压测配置 //压测配置
@ -55,14 +58,20 @@ type SyncConfig struct {
Password string Password string
LocalDir string LocalDir string
RemoteDir string RemoteDir string
ServerIp string ServerIp string
WorkDir string WorkDir string
LubanCli string LubanCli string
DataDir string DataDir string
JsonDir string JsonDir string
SaveDir string //保存目录 SaveDir string //保存目录
LogDir string //远程日志目录 LogDir string //远程日志目录
Editor string //编辑器 Editor string //编辑器
} }
type ServerConfig struct {
SId string
Name string
Url string
}

View File

@ -4,7 +4,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"go_dreamfactory/cmd/v2/lib/common" "go_dreamfactory/cmd/v2/lib/common"
"go_dreamfactory/cmd/v2/service" "go_dreamfactory/cmd/v2/lib/storage"
"go_dreamfactory/cmd/v2/service/observer" "go_dreamfactory/cmd/v2/service/observer"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/modules/user" "go_dreamfactory/modules/user"
@ -158,11 +158,43 @@ func (ui *MainWindowImpl) createChooseServerPopUp(w fyne.Window) error {
return nil return nil
} }
func (ui *MainWindowImpl) configForm(w fyne.Window, call func()) *widget.Form {
//区服编号
sId := widget.NewEntry()
//区服地址
sAddr := widget.NewEntry()
//区服名称
sName := widget.NewEntry()
configForm := widget.NewForm()
configForm.AppendItem(widget.NewFormItem("区服编号", sId))
configForm.AppendItem(widget.NewFormItem("区服地址", sAddr))
configForm.AppendItem(widget.NewFormItem("区服名称", sName))
configForm.OnSubmit = func() {
defer func() {
w.Close()
call()
}()
ui.config.Servers = append(ui.config.Servers, &storage.ServerConfig{
Name: sName.Text,
SId: sId.Text,
Url: sAddr.Text,
})
if err := ui.storage.StoreConfig(ui.config); err != nil {
dialog.ShowError(err, w)
return
}
}
configForm.SubmitText = "保存配置"
configForm.Refresh()
return configForm
}
// createChooseServerWindow // createChooseServerWindow
func (ui *MainWindowImpl) createChooseServerWindow(title string, ch chan string) fyne.Window { func (ui *MainWindowImpl) createChooseServerWindow(title string, ch chan string) fyne.Window {
w := fyne.CurrentApp().NewWindow(title) w := fyne.CurrentApp().NewWindow(title)
// choose server button func // choose server button func
makeButton := func(s *service.ServiceConf, parent fyne.Window) *widget.Button { makeButton := func(s *storage.ServerConfig, parent fyne.Window) *widget.Button {
btn := widget.NewButton(s.Name, func() { btn := widget.NewButton(s.Name, func() {
d := dialog.NewInformation("", common.INFO_WAIT, parent) d := dialog.NewInformation("", common.INFO_WAIT, parent)
d.SetDismissText(common.BUTTON_CANCEL) d.SetDismissText(common.BUTTON_CANCEL)
@ -181,15 +213,47 @@ func (ui *MainWindowImpl) createChooseServerWindow(title string, ch chan string)
} }
sGrid := container.NewGridWithColumns(2) sGrid := container.NewGridWithColumns(2)
config := ui.configService.GetConfig() servers := ui.config.Servers
if config != nil { if len(servers) != 0 {
for _, s := range config.Services { for _, s := range servers {
box := makeButton(s.Service, w) box := makeButton(s, w)
sGrid.Add(box) sGrid.Add(container.NewBorder(nil, nil, nil, widget.NewButtonWithIcon("", theme.DeleteIcon(), func() {
defer func() {
w.Close()
ui.parent.Show()
}()
txt := box.Text
for i, ss := range servers {
if txt == ss.Name {
ui.config.Servers = append(ui.config.Servers[:i], ui.config.Servers[i+1:]...)
i--
}
}
if err := ui.storage.StoreConfig(ui.config); err != nil {
dialog.ShowError(err, w)
}
}), box))
} }
sGrid.Add(widget.NewButtonWithIcon("", theme.ContentAddIcon(), func() {
addWin := fyne.CurrentApp().NewWindow("添加区服")
addWin.SetContent(ui.configForm(addWin, func() {
w.Close()
ui.parent.Show()
}))
addWin.SetFixedSize(true)
addWin.Resize(fyne.NewSize(500, 200))
addWin.Show()
addWin.CenterOnScreen()
}))
w.SetContent(sGrid)
} else {
w.SetContent(ui.configForm(w, func() {
w.Close()
ui.parent.Show()
}))
} }
w.SetContent(sGrid)
w.SetFixedSize(true) w.SetFixedSize(true)
w.Resize(fyne.NewSize(500, 200)) w.Resize(fyne.NewSize(500, 200))
w.Show() w.Show()

View File

@ -52,7 +52,7 @@ func (this *ModelSession) addUserSession(uid string, session comm.IUserSession)
"gatewayServiceId": session.GetGatewayServiceId(), "gatewayServiceId": session.GetGatewayServiceId(),
"ip": session.GetIP(), "ip": session.GetIP(),
}, db.SetDBMgoLog(false)); err != nil { }, db.SetDBMgoLog(false)); err != nil {
log.Debugf("setUserSession err:%v", err) log.Debug("setUserSession err:%v", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err})
return return
} }
return return