mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 14:39:40 -08:00
Merge pull request #284 from prometheus/refactor/storage/notify-when-available
Ensure database access waits until it is started.
This commit is contained in:
commit
52a1e50dda
5
main.go
5
main.go
|
@ -266,7 +266,10 @@ func main() {
|
|||
}
|
||||
defer prometheus.close()
|
||||
|
||||
go ts.Serve()
|
||||
storageStarted := make(chan bool)
|
||||
go ts.Serve(storageStarted)
|
||||
<-storageStarted
|
||||
|
||||
go prometheus.interruptHandler()
|
||||
go prometheus.reportDatabaseState()
|
||||
|
||||
|
|
|
@ -79,8 +79,9 @@ func NewTestTieredStorage(t test.Tester) (storage *metric.TieredStorage, closer
|
|||
directory.Close()
|
||||
t.Fatalf("storage == nil")
|
||||
}
|
||||
|
||||
go storage.Serve()
|
||||
started := make(chan bool)
|
||||
go storage.Serve(started)
|
||||
<-started
|
||||
closer = &testTieredStorageCloser{
|
||||
storage: storage,
|
||||
directory: directory,
|
||||
|
|
|
@ -101,7 +101,10 @@ func NewTestTieredStorage(t test.Tester) (storage *TieredStorage, closer test.Cl
|
|||
t.Fatalf("storage == nil")
|
||||
}
|
||||
|
||||
go storage.Serve()
|
||||
started := make(chan bool)
|
||||
go storage.Serve(started)
|
||||
<-started
|
||||
|
||||
closer = &testTieredStorageCloser{
|
||||
storage: storage,
|
||||
directory: directory,
|
||||
|
|
|
@ -156,7 +156,7 @@ func (t *TieredStorage) MakeView(builder ViewRequestBuilder, deadline time.Durat
|
|||
}
|
||||
|
||||
// Starts serving requests.
|
||||
func (t *TieredStorage) Serve() {
|
||||
func (t *TieredStorage) Serve(started chan<- bool) {
|
||||
flushMemoryTicker := time.NewTicker(t.flushMemoryInterval)
|
||||
defer flushMemoryTicker.Stop()
|
||||
queueReportTicker := time.NewTicker(time.Second)
|
||||
|
@ -168,6 +168,8 @@ func (t *TieredStorage) Serve() {
|
|||
}
|
||||
}()
|
||||
|
||||
started <- true
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-flushMemoryTicker.C:
|
||||
|
|
Loading…
Reference in a new issue