commit 8a55bde4dd8d44bbe52fdd2939f9614174b66d2c
parent f34c656fd5347dd284aa2a7fc5978488233748ac
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Wed, 28 Jun 2023 13:56:56 -0700
cleanup
Diffstat:
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/pkg/pubsub/pubsub.go b/pkg/pubsub/pubsub.go
@@ -99,14 +99,8 @@ func (s *Sub[T]) ReceiveTimeout2(timeout time.Duration, c1 <-chan struct{}) (top
// ReceiveTimeout returns a message received on the channel or timeout
func (s *Sub[T]) ReceiveTimeout(timeout time.Duration) (topic string, msg T, err error) {
- select {
- case p := <-s.ch:
- return p.topic, p.msg, nil
- case <-time.After(timeout):
- return topic, msg, ErrTimeout
- case <-s.ctx.Done():
- return topic, msg, ErrCancelled
- }
+ c1 := make(chan struct{})
+ return s.ReceiveTimeout2(timeout, c1)
}
// Receive returns a message