This commit is contained in:
Georges Chaudy 2024-07-08 12:16:16 +02:00
parent 68a0cf5d81
commit f3c554e668
No known key found for this signature in database
GPG Key ID: 0EE887FFCA1DB6EF
3 changed files with 10 additions and 10 deletions

View File

@ -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{

View File

@ -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 }}

View File

@ -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 {