Call issues client rpc call.
(method string, args interface{}, reply interface{})
| 74 | |
| 75 | // Call issues client rpc call. |
| 76 | func (c *RawCaller) Call(method string, args interface{}, reply interface{}) (err error) { |
| 77 | if !c.isClientValid() { |
| 78 | if err = c.resetClient(); err != nil { |
| 79 | return |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | c.RLock() |
| 84 | err = c.client.Call(method, args, reply) |
| 85 | c.RUnlock() |
| 86 | |
| 87 | if err != nil { |
| 88 | if err == io.EOF || |
| 89 | err == io.ErrUnexpectedEOF || |
| 90 | err == io.ErrClosedPipe || |
| 91 | err == nrpc.ErrShutdown || |
| 92 | strings.Contains(strings.ToLower(err.Error()), "shut down") || |
| 93 | strings.Contains(strings.ToLower(err.Error()), "broken pipe") { |
| 94 | // if got EOF, retry once |
| 95 | reconnectErr := c.resetClient() |
| 96 | if reconnectErr != nil { |
| 97 | err = errors.Wrap(reconnectErr, "reconnect failed") |
| 98 | } |
| 99 | } |
| 100 | err = errors.Wrapf(err, "call %s failed", method) |
| 101 | } |
| 102 | return |
| 103 | } |
| 104 | |
| 105 | // Close release underlying connection resources. |
| 106 | func (c *RawCaller) Close() { |