Skip to content

Commit

Permalink
issue-83: add some descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryk-dk committed Oct 31, 2024
1 parent 5e14137 commit f748fad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/plugin/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataReques
return response, nil
}

// streamQuery sends a query to the datasource and parse the tail results.
func (d *Datasource) streamQuery(ctx context.Context, request *backend.RunStreamRequest) error {
q, err := d.getQueryFromRaw(request.Data)
if err != nil {
Expand All @@ -155,7 +156,7 @@ func (d *Datasource) streamQuery(ctx context.Context, request *backend.RunStream
return parseStreamResponse(r, d.streamCh)
}

// query sends a query to the datasource and returns the result.
// getQueryFromRaw parses the query json from the raw message.
func (d *Datasource) getQueryFromRaw(data json.RawMessage) (*Query, error) {
var q Query
if err := json.Unmarshal(data, &q); err != nil {
Expand All @@ -164,6 +165,7 @@ func (d *Datasource) getQueryFromRaw(data json.RawMessage) (*Query, error) {
return &q, nil
}

// datasourceQuery process the query to the datasource and returns the result.
func (d *Datasource) datasourceQuery(ctx context.Context, q *Query, isStream bool) (io.ReadCloser, error) {

var settings struct {
Expand Down Expand Up @@ -219,6 +221,7 @@ func (d *Datasource) datasourceQuery(ctx context.Context, q *Query, isStream boo
return resp.Body, nil
}

// query sends a query to the datasource and returns the result.
func (d *Datasource) query(ctx context.Context, _ backend.PluginContext, query backend.DataQuery) backend.DataResponse {
q, err := d.getQueryFromRaw(query.JSON)
if err != nil {
Expand Down

0 comments on commit f748fad

Please sign in to comment.