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

Fix missing Kapacitor on Source index page #748

Merged
merged 1 commit into from
Jan 13, 2017
Merged

Conversation

timraymond
Copy link
Contributor

@timraymond timraymond commented Jan 10, 2017

  • CHANGELOG.md updated
  • Rebased/mergable
  • Tests pass
  • Sign CLA (if not already signed)

Connect #702

When visiting the Sources page, any InfluxDB sources that had a
configured Kapacitor would not show them. This turned out to be racey
logic. Kapacitors for a particular source are fetched from the API. The
update to the component state happened outside of the promise chained
onto the API call, so the state update was racing against the fetch from
the API (and would always win, pushing the empty object).

Instead, the chained promises for each API fetch are collected, and each
promise updates a single kapacitors object. The final promise that
updates the state is then blocked on all those promises by Promise.all.

Performing updates like this saves some allocations, since we aren't
allocating an object for each source<->kapacitor pairing to send to
setState. It also reduces setState's work, since it doesn't have to
coalesce state updates.

@121watts
Copy link
Contributor

I can dig it

@timraymond timraymond force-pushed the bugfix/tr-missing-kapa branch from 70d9640 to c5d9918 Compare January 12, 2017 15:24
When visiting the Sources page, any InfluxDB sources that had a
configured Kapacitor would not show them. This turned out to be racey
logic. Kapacitors for a particular source are fetched from the API. The
update to the component state happened outside of the promise chained
onto the API call, so the state update was racing against the fetch from
the API (and would always win, pushing the empty object).

Instead, the chained promises for each API fetch are collected, and each
promise updates a single kapacitors object. The final promise that
updates the state is then blocked on all those promises by Promise.all.

Performing updates like this saves some allocations, since we aren't
allocating an object for each source<->kapacitor pairing to send to
setState. It also reduces setState's work, since it doesn't have to
coalesce state updates.
@timraymond timraymond force-pushed the bugfix/tr-missing-kapa branch from c5d9918 to d35b64f Compare January 13, 2017 20:21
@goller goller merged commit aebc052 into master Jan 13, 2017
@goller goller deleted the bugfix/tr-missing-kapa branch January 13, 2017 20:29
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.

3 participants