[#419] rpc/client: Use provided context for client dial

In previous implementation `Client` passed `context.Background()` to
`grpc.DialContext` function. This didn't allow to abort dial stage by
the given context.

Base dial context on the one provided with `WithContext` option. Fall
back to using `context.Background` if context is not specified.

Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
This commit is contained in:
Leonard Lyubich 2022-10-03 13:34:22 +04:00 committed by LeL
parent 2b89b7e798
commit 3a91383f24
3 changed files with 19 additions and 13 deletions

View file

@ -68,11 +68,11 @@ func (g rwGRPC) WriteMessage(m message.Message) error {
}
func (c *Client) initGRPC(info common.CallMethodInfo, prm *callParameters) (MessageReadWriter, error) {
if err := c.createGRPCClient(); err != nil {
if err := c.createGRPCClient(prm.ctx); err != nil {
return nil, err
}
rw, err := c.gRPCClient.Init(info, prm.callOpts...)
rw, err := c.gRPCClient.Init(info, grpc.WithContext(prm.ctx))
if err != nil {
return nil, err
}