Client¶
Configuration¶
rpc:
client:
test:
desc: "test service"
address:
- url: "127.0.0.1:9000"
codec:
name: json
version: >=1.0, <2
group: api
fail: fast
balancer:
name: random
channels: 4
dial_timeout: 10s
read_timeout: 10s
write_timeout: 10s
Create¶
c := rpc.Dial("json", transport.Address{URL: "127.0.0.1:9000"})
var s string
err := c.Call(context.Background(), "Test", "Hello", []interface{}{"auxo"}, &s)
Fail Mode¶
默认错误处理策略是 FailFast
,当调用服务出错时,即使有多个节点也不会重试。可以通过调整 ClientOptions
的 fail
设置来更改。
Options | Description |
---|---|
fast | FailFast returns error immediately |
over | FailOver selects another node automatically |
try | FailTry use current node again |
Tip
只有超时、服务器端关闭等系统错误才会应用错误处理策略,常规业务错误都会直接返回给调用方。
Resolver¶
TODO
Load Balancing¶
TODO
Filter¶
TODO