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

Add ShouldCacheQuery util for async caching #85

Merged
merged 3 commits into from
Jul 17, 2023
Merged

Add ShouldCacheQuery util for async caching #85

merged 3 commits into from
Jul 17, 2023

Conversation

iwysiu
Copy link
Contributor

@iwysiu iwysiu commented Jul 14, 2023

Adds a utility function so that the caching service in grafana can check whether or not the response should be cached.

The way the async queries work is that the first query is sent to the datasource and returns a queryId (this query always returns the started state unless it errors). This queryID is added to all the following queries, and when one of them returns a done response we stop querying.
Thus, we need to cache the "started" status response (which returns the id), and the "done" status response (which we need the id to get).

part of grafana/grafana-async-query-data-js#14

{
"starting async query should cache",
map[string]interface{}{"status": "started"},
true,
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, what's the explanation for also caching "started" status? There is no result yet, so what is the purpose of caching this one? Noticed here that we only thought about "done" before.
(Can maybe update PR description with any explanation)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(i'll edit the pr description too) The way the async queries work is that the first query is sent to the datasource and returns a queryId (this query always returns the started state unless it errors). This queryID is added to all the following queries, and when one of them returns a done response we stop querying.
Thus, we need to cache the "started" status response (which returns the id), and the "done" status response (which we need the id to get).

@iwysiu iwysiu merged commit 49e4756 into main Jul 17, 2023
3 checks passed
@iwysiu iwysiu deleted the async-caching branch July 17, 2023 17: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.

None yet

3 participants