From 7ebbcbc7e5bcb397f3b9852850632e3678eff18e Mon Sep 17 00:00:00 2001 From: sincos Date: Fri, 19 Jul 2024 13:38:26 +0800 Subject: [PATCH] fix(confmws/confmqtt): fix NewClient, try fetch client by id from cache --- confmws/confmqtt/broker.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/confmws/confmqtt/broker.go b/confmws/confmqtt/broker.go index a62bf10..13fe2f2 100644 --- a/confmws/confmqtt/broker.go +++ b/confmws/confmqtt/broker.go @@ -135,6 +135,10 @@ func (b *Broker) NewClient(id, topic string) (*Client, error) { if topic == "" { return nil, ErrInvalidTopic } + if c, ok := b.clients.Load(id); ok && c != nil { + return c.(*Client), nil + } + option := b.options(id) c := &Client{