mirror of
https://github.com/grafana/grafana.git
synced 2025-01-08 15:13:30 -06:00
more cleanup
This commit is contained in:
parent
9f6709c167
commit
4b4afa1fa7
@ -139,6 +139,10 @@ func (s *sqlResourceStore) WriteEvent(ctx context.Context, event resource.WriteE
|
||||
return 0, ErrNotImplementedYet
|
||||
}
|
||||
|
||||
func (s *sqlResourceStore) Watch(context.Context, *resource.WatchRequest) (chan *resource.WatchEvent, error) {
|
||||
return nil, ErrNotImplementedYet
|
||||
}
|
||||
|
||||
// Create new name for a given resource
|
||||
func (s *sqlResourceStore) GenerateName(_ context.Context, _ *resource.ResourceKey, _ string) (string, error) {
|
||||
return util.GenerateShortUID(), nil
|
||||
|
@ -1,61 +0,0 @@
|
||||
package sqlnext
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/storage/unified/resource"
|
||||
)
|
||||
|
||||
func (s *sqlResourceStore) Watch(context.Context, *resource.WatchRequest) (chan *resource.WatchEvent, error) {
|
||||
return nil, ErrNotImplementedYet
|
||||
}
|
||||
|
||||
func (s *sqlResourceStore) poller(stream chan *resource.WatchEvent) {
|
||||
var err error
|
||||
|
||||
since := int64(0)
|
||||
interval := 1 * time.Second
|
||||
|
||||
t := time.NewTicker(interval)
|
||||
defer t.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-s.ctx.Done():
|
||||
return
|
||||
case <-t.C:
|
||||
since, err = s.poll(since, stream)
|
||||
if err != nil {
|
||||
s.log.Error("watch error", "err", err)
|
||||
}
|
||||
t.Reset(interval)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *sqlResourceStore) poll(since int64, out chan *resource.WatchEvent) (int64, error) {
|
||||
ctx, span := s.tracer.Start(s.ctx, "storage_server.poll")
|
||||
defer span.End()
|
||||
ctxLogger := s.log.FromContext(log.WithContextualAttributes(ctx, []any{"method", "poll"}))
|
||||
|
||||
for hasmore := true; hasmore; {
|
||||
err := func() error {
|
||||
if false {
|
||||
// TODO
|
||||
out <- &resource.WatchEvent{}
|
||||
}
|
||||
|
||||
// TODO, copy from entity store
|
||||
hasmore = false
|
||||
return nil
|
||||
}()
|
||||
if err != nil {
|
||||
ctxLogger.Error("poll error", "error", err)
|
||||
return since, err
|
||||
}
|
||||
}
|
||||
|
||||
return since, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user