Re: [go-nuts] Listen by multiple goroutines via channels
On Mon, 3 Sep 2018 06:22:27 + Anik Hasibul wrote: > Can you please provide an example? I am new to golang. > Create N client receivers with channel and save the list of client channel as list, for x := 0; x < 5; x++ { cl := make(chan int, 1) chanClients = append(chanClients, cl) go clientReceiver(cl) } Then pass the main notification channel and list of client channels to master, and propagate notification to all client channels when data arrived, func masterReceiver(notif chan int, chanClients []chan int) { for n := range notif { for _, ch := range chanClients { ch <- n } } } -- { "github":"github.com/shuLhan", "site":"kilabit.info" } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Listen by multiple goroutines via channels
Can you please provide an example? I am new to golang. From: Mhd Shulhan Sent: Monday, September 3, 2018 12:17:57 PM To: anik3...@gmail.com Cc: golang-nuts Subject: Re: [go-nuts] Listen by multiple goroutines via channels On Mon, 3 Sep 2018, 13:03 , mailto:anik3...@gmail.com>> wrote: I have a postgresql notification listener. And i have thousands of different goroutines. I am waiting to receive a single notification from each goroutine. But only one channel is getting the value. Example: https://play.golang.org/p/1a4cVLad8db But I am expecting, all user `Receiver()` should receive all the values to `ch` That's mean all user will get the value from `1` to `10` Any idea to achieve this? The simple way to achieve this is using N master receiver that propagate value to all client receivers. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Listen by multiple goroutines via channels
On Mon, 3 Sep 2018, 13:03 , wrote: > I have a postgresql notification listener. > > And i have thousands of different goroutines. > > I am waiting to receive a single notification from each goroutine. > > > But only one channel is getting the value. Example: > https://play.golang.org/p/1a4cVLad8db > > > But I am expecting, all user `Receiver()` should receive all the values to > `ch` > > That's mean all user will get the value from `1` to `10` > > Any idea to achieve this? > The simple way to achieve this is using N master receiver that propagate value to all client receivers. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Listen by multiple goroutines via channels
I have a postgresql notification listener. And i have thousands of different goroutines. I am waiting to receive a single notification from each goroutine. But only one channel is getting the value. Example: https://play.golang.org/p/1a4cVLad8db But I am expecting, all user `Receiver()` should receive all the values to `ch` That's mean all user will get the value from `1` to `10` Any idea to achieve this? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.