Created
January 9, 2023 13:08
-
-
Save glober-vaibhav/4a00b63231933f2ba3c4ef1c9ed96d05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Subscribe subscribes to a topic | |
func (b *Agent) Subscribe(topic string) <-chan string { | |
b.mu.Lock() | |
defer b.mu.Unlock() | |
if b.closed { | |
return nil | |
} | |
ch := make(chan string) | |
b.subs[topic] = append(b.subs[topic], ch) | |
return ch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment