|
|
|
@ -37,6 +37,8 @@ var ( |
|
|
|
|
Dial: xtime.Duration(time.Second * 10), |
|
|
|
|
Timeout: xtime.Duration(time.Millisecond * 250), |
|
|
|
|
Subset: 50, |
|
|
|
|
KeepAliveInterval: xtime.Duration(time.Second * 60), |
|
|
|
|
KeepAliveTimeout: xtime.Duration(time.Second * 20), |
|
|
|
|
} |
|
|
|
|
_defaultClient *Client |
|
|
|
|
) |
|
|
|
@ -59,6 +61,9 @@ type ClientConfig struct { |
|
|
|
|
Zone string |
|
|
|
|
Subset int |
|
|
|
|
NonBlock bool |
|
|
|
|
KeepAliveInterval xtime.Duration |
|
|
|
|
KeepAliveTimeout xtime.Duration |
|
|
|
|
KeepAliveWithoutStream bool |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Client is the framework's client side instance, it contains the ctx, opt and interceptors.
|
|
|
|
@ -186,6 +191,12 @@ func (c *Client) SetConfig(conf *ClientConfig) (err error) { |
|
|
|
|
if conf.Subset <= 0 { |
|
|
|
|
conf.Subset = 50 |
|
|
|
|
} |
|
|
|
|
if conf.KeepAliveInterval <= 0 { |
|
|
|
|
conf.KeepAliveInterval = xtime.Duration(time.Second * 60) |
|
|
|
|
} |
|
|
|
|
if conf.KeepAliveTimeout <= 0 { |
|
|
|
|
conf.KeepAliveTimeout = xtime.Duration(time.Second * 20) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// FIXME(maojian) check Method dial/timeout
|
|
|
|
|
c.mutex.Lock() |
|
|
|
|