From 066a2dba74bc32e8aad60a228d14d36f8b097e10 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 31 May 2021 09:16:57 +0300 Subject: [PATCH] [#196] rpc/grpc: Implement Client.Conn method Implement `Client.Conn` method which returns underlying connection as `io.Closer`. Method is going to be used for forwarding the connection to superior clients. Signed-off-by: Leonard Lyubich --- rpc/grpc/conn.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 rpc/grpc/conn.go diff --git a/rpc/grpc/conn.go b/rpc/grpc/conn.go new file mode 100644 index 0000000..40968b9 --- /dev/null +++ b/rpc/grpc/conn.go @@ -0,0 +1,19 @@ +package grpc + +import ( + "io" +) + +// Conn returns underlying connection. +// +// 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.con + } + + return nil +}