-
Notifications
You must be signed in to change notification settings - Fork 490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(topics): make topic queue length configurable #2661
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few non-blocking suggestions.
alert/topics.go
Outdated
} | ||
|
||
func NewTopics() *Topics { | ||
func NewTopics(bufferSize int) *Topics { | ||
if bufferSize <= 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want a larger minimum, like 1K or something? I cold see a 3-byte buffer causing problems.
alert/topics.go
Outdated
@@ -385,10 +389,13 @@ type bufHandler struct { | |||
wg sync.WaitGroup | |||
} | |||
|
|||
func newHandler(h Handler) *bufHandler { | |||
func newHandler(h Handler, bufferSize int) *bufHandler { | |||
if bufferSize == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the difference in safety checks: above you use <= 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 -- this is actually a bug imho since bufferSize
is an int
. this would panic 100% if someone passed in, say, -1.
7dab35a
to
5a8696e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more suggestion because I was wrong the last review.
alert/topics.go
Outdated
|
||
collected *expvar.Int | ||
statsKey string | ||
|
||
handlers []*bufHandler | ||
} | ||
|
||
func newTopic(id string) *Topic { | ||
func newTopic(id string, bufferLength int) *Topic { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this was the one I thought should be a method of the Topics struct, so bufferLength
is magically available. My mistake on NewTopics()
being a method of the thing that it created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually a good idea.
@@ -385,10 +391,13 @@ type bufHandler struct { | |||
wg sync.WaitGroup | |||
} | |||
|
|||
func newHandler(h Handler) *bufHandler { | |||
func newHandler(h Handler, bufferSize int) *bufHandler { | |||
if bufferSize < MinimumEventBufferSize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
5a8696e
to
faedd69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@docmerlin -- docs will need the name of the config parameter, along with its default value....and where it appears in the config file. Essentially, the config documentation needs to be updated to describe how customers can set this. |
This is a tuning param to make the topic queue length configurable. This is useful if very large amounts of alerts must go off due to scheduled maintenance etc such as a windows update.