mirror of
https://github.com/grafana/grafana.git
synced 2025-01-08 15:13:30 -06:00
watch
This commit is contained in:
parent
68a0cf5d81
commit
f3c554e668
@ -446,7 +446,7 @@ func (b *backend) poll(ctx context.Context, since int64, stream chan<- *resource
|
||||
pollReq := sqlResourceHistoryPollRequest{
|
||||
SQLTemplate: sqltemplate.New(b.sqlDialect),
|
||||
SinceResourceVersion: since,
|
||||
historyPollResponse: new(historyPollResponse),
|
||||
Response: new(historyPollResponse),
|
||||
}
|
||||
query, err := sqltemplate.Execute(sqlResourceHistoryPoll, pollReq)
|
||||
if err != nil {
|
||||
@ -465,7 +465,7 @@ func (b *backend) poll(ctx context.Context, since int64, stream chan<- *resource
|
||||
if err := rows.Scan(pollReq.GetScanDest()...); err != nil {
|
||||
return 0, fmt.Errorf("scan row #%d polling for resource history: %w", i, err)
|
||||
}
|
||||
resp := *pollReq.historyPollResponse
|
||||
resp := pollReq.Response
|
||||
next = resp.ResourceVersion
|
||||
|
||||
stream <- &resource.WrittenEvent{
|
||||
|
@ -1,11 +1,11 @@
|
||||
SELECT
|
||||
{{ .Ident "resource_version" | .Into .ResourceVersion }},
|
||||
{{ .Ident "namespace" | .Into .Key.Namespace }},
|
||||
{{ .Ident "group" | .Into .Key.Group }},
|
||||
{{ .Ident "resource" | .Into .Key.Resource }},
|
||||
{{ .Ident "name" | .Into .Key.Name }},
|
||||
{{ .Ident "value" | .Into .Value }},
|
||||
{{ .Ident "action" | .Into .Action }}
|
||||
{{ .Ident "resource_version" | .Into .Response.ResourceVersion }},
|
||||
{{ .Ident "namespace" | .Into .Response.Key.Namespace }},
|
||||
{{ .Ident "group" | .Into .Response.Key.Group }},
|
||||
{{ .Ident "resource" | .Into .Response.Key.Resource }},
|
||||
{{ .Ident "name" | .Into .Response.Key.Name }},
|
||||
{{ .Ident "value" | .Into .Response.Value }},
|
||||
{{ .Ident "action" | .Into .Response.Action }}
|
||||
|
||||
FROM {{ .Ident "resource_history" }}
|
||||
WHERE {{ .Ident "resource_version" }} > {{ .Arg .SinceResourceVersion }}
|
||||
|
@ -106,7 +106,7 @@ func (r *historyPollResponse) Results() (*historyPollResponse, error) {
|
||||
type sqlResourceHistoryPollRequest struct {
|
||||
*sqltemplate.SQLTemplate
|
||||
SinceResourceVersion int64
|
||||
*historyPollResponse
|
||||
Response *historyPollResponse
|
||||
}
|
||||
|
||||
func (r sqlResourceHistoryPollRequest) Validate() error {
|
||||
|
Loading…
Reference in New Issue
Block a user