From 22ce8e13ccb6a9a72747d34fbfbfe09d8d3b61a4 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 31 May 2021 09:18:23 +0300 Subject: [PATCH] [#196] rpc/client: Implement Client.Conn method Implement `Client.Conn` which returns the connection of the underlying transport client. The method is going to be used for forwarding the connection to superior clients. Signed-off-by: Leonard Lyubich --- rpc/client/conn.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 rpc/client/conn.go diff --git a/rpc/client/conn.go b/rpc/client/conn.go new file mode 100644 index 0000000..ba53ab3 --- /dev/null +++ b/rpc/client/conn.go @@ -0,0 +1,22 @@ +package client + +import ( + "io" +) + +// Conn returns underlying connection. +// +// Returns non-nil result after the first Init() call +// completed without a connection error. +// +// Conn is NPE-safe: returns nil if Client is nil. +// +// Client should not be used after Close() call +// on the connection: behavior is undefined. +func (c *Client) Conn() io.Closer { + if c != nil { + return c.gRPCClient.Conn() + } + + return nil +}