本文整理汇总了Golang中github.com/litl/shuttle/client.ServiceConfig.ServerTimeout方法的典型用法代码示例。如果您正苦于以下问题:Golang ServiceConfig.ServerTimeout方法的具体用法?Golang ServiceConfig.ServerTimeout怎么用?Golang ServiceConfig.ServerTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/litl/shuttle/client.ServiceConfig
的用法示例。
在下文中一共展示了ServiceConfig.ServerTimeout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: setServiceDefaults
// set any missing global configuration on a new ServiceConfig.
// ServiceRegistry *must* be locked.
func (s *ServiceRegistry) setServiceDefaults(svc *client.ServiceConfig) {
if svc.Balance == "" && s.cfg.Balance != "" {
svc.Balance = s.cfg.Balance
}
if svc.CheckInterval == 0 && s.cfg.CheckInterval != 0 {
svc.CheckInterval = s.cfg.CheckInterval
}
if svc.Fall == 0 && s.cfg.Fall != 0 {
svc.Fall = s.cfg.Fall
}
if svc.Rise == 0 && s.cfg.Rise != 0 {
svc.Rise = s.cfg.Rise
}
if svc.ClientTimeout == 0 && s.cfg.ClientTimeout != 0 {
svc.ClientTimeout = s.cfg.ClientTimeout
}
if svc.ServerTimeout == 0 && s.cfg.ServerTimeout != 0 {
svc.ServerTimeout = s.cfg.ServerTimeout
}
if svc.DialTimeout == 0 && s.cfg.DialTimeout != 0 {
svc.DialTimeout = s.cfg.DialTimeout
}
if s.cfg.HTTPSRedirect {
svc.HTTPSRedirect = true
}
}
示例2: TestUpdateServiceDefaults
func (s *HTTPSuite) TestUpdateServiceDefaults(c *C) {
svcCfg := client.ServiceConfig{
Name: "TestService",
Addr: "127.0.0.1:9000",
Backends: []client.BackendConfig{
client.BackendConfig{
Name: "Backend1",
Addr: "127.0.0.1:9001",
},
},
}
svcDef := bytes.NewBuffer(svcCfg.Marshal())
req, _ := http.NewRequest("PUT", s.httpSvr.URL+"/TestService", svcDef)
resp, err := http.DefaultClient.Do(req)
if err != nil {
c.Fatal(err)
}
resp.Body.Close()
// Now update the Service in-place
svcCfg.ServerTimeout = 1234
svcDef.Reset()
svcDef.Write(svcCfg.Marshal())
req, _ = http.NewRequest("PUT", s.httpSvr.URL+"/TestService", svcDef)
resp, err = http.DefaultClient.Do(req)
if err != nil {
c.Fatal(err)
}
body, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
config := client.Config{}
err = json.Unmarshal(body, &config)
if err != nil {
c.Fatal(err)
}
// make sure we don't see a second value
found := false
for _, svc := range config.Services {
if svc.Name == "TestService" {
if svc.ServerTimeout != svcCfg.ServerTimeout {
c.Fatal("Service not updated")
} else if found {
c.Fatal("Multiple Service Definitions")
}
found = true
}
}
}
示例3: TestUpdateService
// check valid service updates
func (s *BasicSuite) TestUpdateService(c *C) {
svcCfg := client.ServiceConfig{
Name: "Update2",
Addr: "127.0.0.1:9324",
}
if err := Registry.AddService(svcCfg); err != nil {
c.Fatal(err)
}
svc := Registry.GetService("Update2")
if svc == nil {
c.Fatal(ErrNoService)
}
svcCfg.ServerTimeout = 1234
svcCfg.HTTPSRedirect = true
svcCfg.Fall = 5
svcCfg.Rise = 6
svcCfg.Balance = "LC"
// Now update the service for real
if err := Registry.UpdateService(svcCfg); err != nil {
c.Fatal(err)
}
svc = Registry.GetService("Update2")
if svc == nil {
c.Fatal(ErrNoService)
}
c.Assert(svc.ServerTimeout, Equals, 1234*time.Millisecond)
c.Assert(svc.HTTPSRedirect, Equals, true)
c.Assert(svc.Fall, Equals, 5)
c.Assert(svc.Rise, Equals, 6)
c.Assert(svc.Balance, Equals, "LC")
if err := Registry.RemoveService("Update2"); err != nil {
c.Fatal(err)
}
}