From 3cfb76c46e19949b6c9694baf4f8d831e8133642 Mon Sep 17 00:00:00 2001 From: Max Truxa Date: Thu, 10 Jun 2021 03:03:45 +0200 Subject: [PATCH 1/2] drpcmanager: expose termination signal --- drpcmanager/README.md | 4 ++-- drpcmanager/manager.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drpcmanager/README.md b/drpcmanager/README.md index 853af2d..cfb22c8 100644 --- a/drpcmanager/README.md +++ b/drpcmanager/README.md @@ -43,9 +43,9 @@ Close closes the transport the manager is using. #### func (*Manager) Closed ```go -func (m *Manager) Closed() bool +func (m *Manager) Closed() <-chan struct{} ``` -Closed returns if the manager has been closed. +Closed returns a channel that is closed once the manager is closed #### func (*Manager) NewClientStream diff --git a/drpcmanager/manager.go b/drpcmanager/manager.go index 21e2111..b6dc591 100644 --- a/drpcmanager/manager.go +++ b/drpcmanager/manager.go @@ -171,9 +171,9 @@ func (m *Manager) waitForPreviousStream(ctx context.Context) (err error) { // exported interface // -// Closed returns if the manager has been closed. -func (m *Manager) Closed() bool { - return m.term.IsSet() +// Closed returns a channel that is closed once the manager is closed. +func (m *Manager) Closed() <-chan struct{} { + return m.term.Signal() } // Close closes the transport the manager is using. From 90b2e9de60dbd3b715642f0b1279247fa14ae628 Mon Sep 17 00:00:00 2001 From: Max Truxa Date: Thu, 10 Jun 2021 03:06:19 +0200 Subject: [PATCH 2/2] drpcconn: expose termination signal --- drpc.go | 4 ++-- drpcconn/README.md | 4 ++-- drpcconn/conn.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drpc.go b/drpc.go index 3a9b2ef..be4fedd 100644 --- a/drpc.go +++ b/drpc.go @@ -34,8 +34,8 @@ type Conn interface { // Close closes the connection. Close() error - // Closed returns true if the connection is definitely closed. - Closed() bool + // Closed returns a channel that is closed if the connection is definitely closed. + Closed() <-chan struct{} // Transport returns the transport the connection is using. Transport() Transport diff --git a/drpcconn/README.md b/drpcconn/README.md index 8e3f6a3..51df90b 100644 --- a/drpcconn/README.md +++ b/drpcconn/README.md @@ -40,9 +40,9 @@ Close closes the connection. #### func (*Conn) Closed ```go -func (c *Conn) Closed() bool +func (c *Conn) Closed() <-chan struct{} ``` -Closed returns true if the connection is already closed. +Closed returns a channel that is closed once the connection is closed. #### func (*Conn) Invoke diff --git a/drpcconn/conn.go b/drpcconn/conn.go index 3e84f2d..e5764b3 100644 --- a/drpcconn/conn.go +++ b/drpcconn/conn.go @@ -50,8 +50,8 @@ func (c *Conn) Transport() drpc.Transport { return c.tr } -// Closed returns true if the connection is already closed. -func (c *Conn) Closed() bool { +// Closed returns a channel that is closed once the connection is closed. +func (c *Conn) Closed() <-chan struct{} { return c.man.Closed() }