diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index 7d280af5e..4c2fbaa73 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -93,10 +93,10 @@ func Main() int { return 1 } - remoteStorage := &remote.Storage{} - sampleAppender = append(sampleAppender, remoteStorage) + remoteAppender := &remote.Writer{} + sampleAppender = append(sampleAppender, remoteAppender) remoteReader := &remote.Reader{} - reloadables = append(reloadables, remoteStorage, remoteReader) + reloadables = append(reloadables, remoteAppender, remoteReader) queryable := fanin.Queryable{ Local: localStorage, @@ -185,7 +185,7 @@ func Main() int { } }() - defer remoteStorage.Stop() + defer remoteAppender.Stop() // The storage has to be fully initialized before registering. if instrumentedStorage, ok := localStorage.(prometheus.Collector); ok { diff --git a/storage/remote/remote.go b/storage/remote/write.go similarity index 79% rename from storage/remote/remote.go rename to storage/remote/write.go index c67e4f7f4..069ea0a41 100644 --- a/storage/remote/remote.go +++ b/storage/remote/write.go @@ -21,16 +21,16 @@ import ( "github.com/prometheus/prometheus/config" ) -// Storage allows queueing samples for remote writes. -type Storage struct { +// Writer allows queueing samples for remote writes. +type Writer struct { mtx sync.RWMutex queues []*QueueManager } // ApplyConfig updates the state as the new config requires. -func (s *Storage) ApplyConfig(conf *config.Config) error { - s.mtx.Lock() - defer s.mtx.Unlock() +func (w *Writer) ApplyConfig(conf *config.Config) error { + w.mtx.Lock() + defer w.mtx.Unlock() newQueues := []*QueueManager{} // 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() } - s.queues = newQueues - for _, q := range s.queues { + w.queues = newQueues + for _, q := range w.queues { q.Start() } return nil } // Stop the background processing of the storage queues. -func (s *Storage) Stop() { - for _, q := range s.queues { +func (w *Writer) Stop() { + for _, q := range w.queues { q.Stop() } } // Append implements storage.SampleAppender. Always returns nil. -func (s *Storage) Append(smpl *model.Sample) error { - s.mtx.RLock() - defer s.mtx.RUnlock() +func (w *Writer) Append(smpl *model.Sample) error { + w.mtx.RLock() + defer w.mtx.RUnlock() - for _, q := range s.queues { + for _, q := range w.queues { q.Append(smpl) } return nil @@ -85,6 +85,6 @@ func (s *Storage) Append(smpl *model.Sample) error { // NeedsThrottling implements storage.SampleAppender. It will always return // false as a remote storage drops samples on the floor if backlogging instead // of asking for throttling. -func (s *Storage) NeedsThrottling() bool { +func (w *Writer) NeedsThrottling() bool { return false }