func New(zone int, cfg *Config) (p *Client) { p = new(Client) if cfg != nil { p.Config = *cfg } p.mac = qbox.NewMac(p.AccessKey, p.SecretKey) p.Client = rpc.Client{qbox.NewClient(p.mac, p.Transport)} if p.RSHost == "" { p.RSHost = defaultRsHost } if p.RSFHost == "" { p.RSFHost = defaultRsfHost } if zone < 0 || zone >= len(zones) { panic("invalid config: invalid zone") } if len(p.UpHosts) == 0 { p.UpHosts = zones[zone].UpHosts } if p.IoHost == "" { p.IoHost = zones[zone].IoHost } return }
func New(zone int, cfg *Config) (p *Client) { p = new(Client) if cfg != nil { p.Config = *cfg } p.mac = qbox.NewMac(p.AccessKey, p.SecretKey) p.Client = rpc.Client{qbox.NewClient(p.mac, p.Transport)} if p.RSHost == "" { p.RSHost = defaultRsHost } if p.RSFHost == "" { p.RSFHost = defaultRsfHost } if p.Scheme != "https" { p.Scheme = "http" } if p.APIHost == "" { p.APIHost = api.DefaultApiHost } p.apiCli = api.NewClient(p.APIHost, p.Scheme) if zone < 0 || zone >= len(zones) { return } if len(p.UpHosts) == 0 { p.UpHosts = zones[zone].UpHosts } if p.IoHost == "" { p.IoHost = zones[zone].IoHost } return }