-
Notifications
You must be signed in to change notification settings - Fork 67
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
Query conversion handler #1078
Query conversion handler #1078
Conversation
backend/query_conversion.go
Outdated
|
||
type QueryConversionResponse struct { | ||
// Converted query. It should extend v0alpha1.Query | ||
Query any `json:"query"` |
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.
Note: I had to use a explicit any
here rather than make this a generic struct (type QueryConversionResponse[T any] struct
) because either the generic conversion bubbles up until the Manage function and therefore becomes a breaking change, or the type is specifically set to any
in any of the intermediate structs but then the plugin needs to explicitly use also any
on its implementation, making the use of generics unnecessary.
Let me know if I am missing something here.
@ryantxu I believe I have addressed your comments, please take a look again! |
okay, this should now be ready for a final review 👍 |
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.
LGTM! Awesome work on this.
|
||
"github.com/grafana/grafana-plugin-sdk-go/genproto/pluginv2" | ||
) | ||
|
||
type conversionSDKAdapter struct { | ||
handler ConversionHandler | ||
handler ConversionHandler | ||
queryConversionHandler QueryConversionHandler |
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.
Nit: Would be good to document/note that this is optional (just for the sake of knowing not to skip nil checks if anyone is going to change any code here)
What this PR does / why we need it:
Adds a wrapper around the
ConversionHandler
for the specific case of queries. That way if a plugin implements aConvertQuery
, the SDK will automatically translateConversionHandler
requests back and forth and migrate queries.This is a rework of #1071 but in this case, the
ConvertQuery
function is not explicitly called in the QueryData flow, so the plugin needs to manually call theConvertQuery
function on theirQueryData
where they see fit.WIP usage in Grafana as an api server: https://github.com/grafana/grafana/pull/92909/files
See an example usage at grafana/grafana-plugin-examples#340
Which issue(s) this PR fixes:
First part of grafana/grafana#92749
Special notes for your reviewer: