Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

fix notifier handler #602

Merged
merged 2 commits into from
Apr 12, 2017
Merged

fix notifier handler #602

merged 2 commits into from
Apr 12, 2017

Conversation

Dieterbe
Copy link
Contributor

  • gracefully handle the case where persist messages come in for
    aggregations that are not/no longer active.
    (previously : nil pointer panic)
  • handle 'last' aggregation messages
  • crash if unknown consolidation message. because that should
    never happen.

* gracefully handle the case where persist messages come in for
  aggregations that are not/no longer active.
  (previously : nil pointer panic)
* handle 'last' aggregation messages
* crash if unknown consolidation message. because that should
  never happen.
@@ -66,6 +66,12 @@ func NewAggMetric(store Store, cachePusher cache.CachePusher, key string, retent
return &m
}

func (a *AggMetric) maybeSyncChunkSaveState(ts uint32) {
Copy link
Member

Choose a reason for hiding this comment

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

i really dont like the name "maybeSyncChunkSaveState".
I would much rather you just wrapped the calls to SyncChunkSaveState in if cntMetrc != nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why ? This is more concise

Copy link
Member

Choose a reason for hiding this comment

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

"maybe*" is so cryptic. how is someone who reads this code supposed to know what maybeSyncChunkSaveState means. Under what conditions might this function save the chunkSaveState and under what conditions might it not.

Copy link
Contributor

@replay replay Apr 11, 2017

Choose a reason for hiding this comment

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

In the chunk cache i've had a similar problem with the method CacheIfHot. It doesn't always execute it's function, only if a condition is met, so I've simply put the condition into the name to make it self explanatory.
Similarly you could maybe name it syncIfObject or something like that

Copy link
Contributor Author

@Dieterbe Dieterbe Apr 11, 2017

Choose a reason for hiding this comment

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

I went with the maybe* because:

  1. I thought we could establish that as a convention (that maybeX means execute X if the receiver is not nil)
  2. I've used the same convention in other projects/languages
  3. we can also clarify the behavior in a doc comment (but that still doesn't make it obvious when reading the code from the call site)

But I don't care that much. And making it more explicit at the expense of a few sloc works for me, so i pushed that change.

@Dieterbe Dieterbe merged commit cb30554 into master Apr 12, 2017
@Dieterbe Dieterbe deleted the fix-notifier-handler branch September 18, 2018 09:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants