package storage

import "go_dreamfactory/pb"

// 默认配置
func NewDefaultConfig() *Config {
	return &Config{
		Pressure: PressureConfig{
			TimeoutMs:   50,
			Concurrency: 10,
			DurationS:   5,
		},
		UserCount:  100,
		UpgradeUrl: "http://10.0.0.9:8080/",
		Servers: []*ServerConfig{
			{
				SId:  "df01",
				Url:  "ws://119.3.89.14:9891/gateway",
				Name: "外网",
			},
			{
				SId:  "df01",
				Url:  "ws://10.0.0.9:7891/gateway",
				Name: "测试服",
			},
		},
	}
}

type Config struct {
	Pressure      PressureConfig    `json:"Pressure,omitempty"`
	UserCount     int32             `json:"UserCount,omitempty"`     //用户数
	SId           string            `json:"sid,omitempty"`           //区服ID
	WsAddr        string            `json:"wsAddr,omitempty"`        //websocket addr
	IntervalS     int32             `json:"intervalS,omitempty"`     //间隔时间s
	LubanConf     *LubanConfig      `json:"lubanConf,omitempty"`     //luban工具配置
	PbConf        *ProtobufConfig   `json:"pbConf,omitempty"`        //Pb配置
	SyncConf      *SyncConfig       `json:"syncConf,omitempty"`      //同步配置
	UpgradeUrl    string            `json:"upgradeUrl,omitempty"`    //升级服务
	Servers       []*ServerConfig   `json:"servers,omitempty"`       //区服配置
	MgoDB         *MgoDB            `json:"mgoDB,omitempty"`         //MongoDB配置
	ServiceDBInfo *pb.ServiceDBInfo `json:"serviceDBInfo,omitempty"` //
	JsonDir       string            `json:"jsonDir,omitempty"`       //json配置目录
	PingConf      *PingConf         `json:"pingConf,omitempty"`      //ping配置
	MultiMgo      map[string]*MgoDB `json:"multiMgo,omitempty"`      //MongoDBMap
}

type PingConf struct {
	Host  string
	Ports string
}

type MgoDB struct {
	Name     string `json:"name,omitempty"` //
	Host     string `json:"host,omitempty"`
	Port     int32  `json:"port,omitempty"`
	User     string `json:"user,omitempty"`
	Password string `json:"password,omitempty"`
	Database string `json:"database,omitempty"`
}

// 压测配置
type PressureConfig struct {
	TimeoutMs   int32 `json:"timeout,omitempty"`     //超时时间 毫秒
	Concurrency int32 `json:"concurrency,omitempty"` //并发量
	DurationS   int32 `json:"duration,omitempty"`    //持续时间 秒
}

// luban
type LubanConfig struct {
	ServerAddr    string
	ProjectDir    string
	WorkDir       string
	Client        string
	GenType       string
	TmpDir        string
	InputDir      string //输入目录
	OutputCodeDir string //输出Code目录
	OutputJsonDir string //输出json目录
}

type ProtobufConfig struct {
	ProtoDir  string
	OutputDir string
}

type SyncConfig struct {
	Ip        string
	Port      string
	UserName  string
	Password  string
	LocalDir  string
	RemoteDir string

	ServerIp string
	WorkDir  string
	LubanCli string
	DataDir  string
	JsonDir  string

	SaveDir string //保存目录
	LogDir  string //远程日志目录
	Editor  string //编辑器
}

type ServerConfig struct {
	SId  string
	Name string
	Url  string
}
