From 6355144b8c3514cccc5c2ab4f7c4fd8e76a1a9fc Mon Sep 17 00:00:00 2001 From: hozan23 Date: Sun, 23 Jun 2024 15:57:43 +0200 Subject: Fix the issue with message dispatcher and channels Resolved a previous error where each subscription would create a new channel with the fixed buffer size. This caused blocking when the channel buffer was full, preventing the client from handling additional messages. Now, there is a `subscriptions` struct that holds a queue for receiving notifications, ensuring the notify function does not block. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 4a5a737..db4d038 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,14 @@ if err != nil { } defer client.Close() -subID, ch, err := client.Subscribe("RPCService.log_subscribe", nil) +sub, err := client.Subscribe("RPCService.log_subscribe", nil) if err != nil { log.Fatal(err) } -log.Infof("Subscribed successfully: %d\n", subID) +log.Infof("Subscribed successfully: %d\n", sub.ID) go func() { - for notification := range ch { + for notification := range sub.Recv() { log.Infof("Receive new notification: %s\n", notification) } }() -- cgit v1.2.3