Skip to content
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

Merged
merged 1 commit into from
Dec 9, 2021
Merged

Conversation

docmerlin
Copy link
Contributor

@docmerlin docmerlin commented Dec 7, 2021

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.

Copy link
Contributor

@davidby-influx davidby-influx left a 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 {
Copy link
Contributor

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 Show resolved Hide resolved
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 {
Copy link
Contributor

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

Copy link

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.

Copy link
Contributor

@davidby-influx davidby-influx left a 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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@docmerlin docmerlin merged commit af204c7 into master Dec 9, 2021
@docmerlin docmerlin deleted the topicqueueleng branch December 9, 2021 17:58
@timhallinflux
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants