'Channel frequency counter
I have a channel that emits events. I'd like to set up an "oscillometer" on top of this channel, i.e. some sort of a "frequency counter" that gets constantly updated (with some interval, of course, e.g. one second).
My first thought is to create a counter that will be incremented every time an event arrives on the channel and then have a ticker that every second prints out this counter and resets it to 0. It looks like the most straightforward approach, but I'm wondering if, maybe, there are some built-in tools for this in Go? Or maybe some libraries that can do it for me (I've tried finding one, but haven't succeeded)?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|