-
Notifications
You must be signed in to change notification settings - Fork 129
Apply smart refetchInterval
to all resource tables
#7216
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
base: main
Are you sure you want to change the base?
Conversation
refetchIntervalInBackground
to all resource tablesrefetchIntervalInBackground
to all resource tables
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.
However, for dashboards, reports, and alerts tables, this approach isn't required
For dashboards especially, we would like to poll the ListResources
API when the resource has not finished reconciling. This will particularly help the UX when deploying projects (see my comment in the setup.ts
file).
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.
Rather than repeating the refetch function across each resource file, can we put it in one central location? Maybe features/projects
would be the right directory?
Additionally, mind updating the PR description? |
refetchIntervalInBackground
to all resource tablesrefetchInterval
to all resource tables
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.
refetchInterval: (query) => { | ||
const newInterval = calculateRefetchInterval( | ||
currentRefetchInterval, | ||
query.state.data, | ||
query, | ||
); | ||
if (newInterval === false) { | ||
currentRefetchInterval = INITIAL_REFETCH_INTERVAL; | ||
return false; | ||
} | ||
currentRefetchInterval = newInterval; | ||
return newInterval; | ||
}, |
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.
Tracking state outside of the calculateRefetchInterval
function makes this more complex than it feels like it should be. I'm wondering if there's a way calculateRefetchInterval
could encompass all of the logic, so we could call it like this:
query: {
...
refetchInterval: calculateRefetchInterval // more descriptive name could be something like `pollUntilResourcesReconciled`
}
One idea, could we add custom state to either query.meta
or query.state
, e.g. query.state.currentRefetchInterval = X
?
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.
Agreed that we should keep the refetchInterval state encapsulated within the component.
Closes #6667
In this pull request, we introduced a custom refetch interval to repeatedly reload a resource until its status was marked as complete. That same custom refetch interval is being applied to dashboards, alerts, and reports.
Checklist: