Rename remote.Storage to remote.Writer
This commit is contained in:
parent
02395a224d
commit
406b65d0dc
|
@ -93,10 +93,10 @@ func Main() int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteStorage := &remote.Storage{}
|
remoteAppender := &remote.Writer{}
|
||||||
sampleAppender = append(sampleAppender, remoteStorage)
|
sampleAppender = append(sampleAppender, remoteAppender)
|
||||||
remoteReader := &remote.Reader{}
|
remoteReader := &remote.Reader{}
|
||||||
reloadables = append(reloadables, remoteStorage, remoteReader)
|
reloadables = append(reloadables, remoteAppender, remoteReader)
|
||||||
|
|
||||||
queryable := fanin.Queryable{
|
queryable := fanin.Queryable{
|
||||||
Local: localStorage,
|
Local: localStorage,
|
||||||
|
@ -185,7 +185,7 @@ func Main() int {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
defer remoteStorage.Stop()
|
defer remoteAppender.Stop()
|
||||||
|
|
||||||
// The storage has to be fully initialized before registering.
|
// The storage has to be fully initialized before registering.
|
||||||
if instrumentedStorage, ok := localStorage.(prometheus.Collector); ok {
|
if instrumentedStorage, ok := localStorage.(prometheus.Collector); ok {
|
||||||
|
|
|
@ -21,16 +21,16 @@ import (
|
||||||
"github.com/prometheus/prometheus/config"
|
"github.com/prometheus/prometheus/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Storage allows queueing samples for remote writes.
|
// Writer allows queueing samples for remote writes.
|
||||||
type Storage struct {
|
type Writer struct {
|
||||||
mtx sync.RWMutex
|
mtx sync.RWMutex
|
||||||
queues []*QueueManager
|
queues []*QueueManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApplyConfig updates the state as the new config requires.
|
// ApplyConfig updates the state as the new config requires.
|
||||||
func (s *Storage) ApplyConfig(conf *config.Config) error {
|
func (w *Writer) ApplyConfig(conf *config.Config) error {
|
||||||
s.mtx.Lock()
|
w.mtx.Lock()
|
||||||
defer s.mtx.Unlock()
|
defer w.mtx.Unlock()
|
||||||
|
|
||||||
newQueues := []*QueueManager{}
|
newQueues := []*QueueManager{}
|
||||||
// TODO: we should only stop & recreate queues which have changes,
|
// TODO: we should only stop & recreate queues which have changes,
|
||||||
|
@ -53,30 +53,30 @@ func (s *Storage) ApplyConfig(conf *config.Config) error {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, q := range s.queues {
|
for _, q := range w.queues {
|
||||||
q.Stop()
|
q.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
s.queues = newQueues
|
w.queues = newQueues
|
||||||
for _, q := range s.queues {
|
for _, q := range w.queues {
|
||||||
q.Start()
|
q.Start()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop the background processing of the storage queues.
|
// Stop the background processing of the storage queues.
|
||||||
func (s *Storage) Stop() {
|
func (w *Writer) Stop() {
|
||||||
for _, q := range s.queues {
|
for _, q := range w.queues {
|
||||||
q.Stop()
|
q.Stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append implements storage.SampleAppender. Always returns nil.
|
// Append implements storage.SampleAppender. Always returns nil.
|
||||||
func (s *Storage) Append(smpl *model.Sample) error {
|
func (w *Writer) Append(smpl *model.Sample) error {
|
||||||
s.mtx.RLock()
|
w.mtx.RLock()
|
||||||
defer s.mtx.RUnlock()
|
defer w.mtx.RUnlock()
|
||||||
|
|
||||||
for _, q := range s.queues {
|
for _, q := range w.queues {
|
||||||
q.Append(smpl)
|
q.Append(smpl)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -85,6 +85,6 @@ func (s *Storage) Append(smpl *model.Sample) error {
|
||||||
// NeedsThrottling implements storage.SampleAppender. It will always return
|
// NeedsThrottling implements storage.SampleAppender. It will always return
|
||||||
// false as a remote storage drops samples on the floor if backlogging instead
|
// false as a remote storage drops samples on the floor if backlogging instead
|
||||||
// of asking for throttling.
|
// of asking for throttling.
|
||||||
func (s *Storage) NeedsThrottling() bool {
|
func (w *Writer) NeedsThrottling() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
Loading…
Reference in New Issue