| OLD | NEW |
| 1 package alerting | 1 package alerting |
| 2 | 2 |
| 3 import ( | 3 import ( |
| 4 "database/sql" | 4 "database/sql" |
| 5 "encoding/json" | 5 "encoding/json" |
| 6 "fmt" | 6 "fmt" |
| 7 "math" | 7 "math" |
| 8 "net/http" | 8 "net/http" |
| 9 "strconv" | 9 "strconv" |
| 10 "time" | 10 "time" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 ret := []*types.ClusterSummary{} | 128 ret := []*types.ClusterSummary{} |
| 129 | 129 |
| 130 for rows.Next() { | 130 for rows.Next() { |
| 131 var body string | 131 var body string |
| 132 var id int64 | 132 var id int64 |
| 133 if err := rows.Scan(&id, &body); err != nil { | 133 if err := rows.Scan(&id, &body); err != nil { |
| 134 return nil, fmt.Errorf("Failed to read row from database
: %s", err) | 134 return nil, fmt.Errorf("Failed to read row from database
: %s", err) |
| 135 } | 135 } |
| 136 c := &types.ClusterSummary{} | 136 c := &types.ClusterSummary{} |
| 137 if err := json.Unmarshal([]byte(body), c); err != nil { | 137 if err := json.Unmarshal([]byte(body), c); err != nil { |
| 138 » » » glog.Errorf("Found invalid JSON in clusters table: %s %s
", id, err) | 138 » » » glog.Errorf("Found invalid JSON in clusters table: %d %s
", id, err) |
| 139 return nil, fmt.Errorf("Failed to read row from database
: %s", err) | 139 return nil, fmt.Errorf("Failed to read row from database
: %s", err) |
| 140 } | 140 } |
| 141 c.ID = id | 141 c.ID = id |
| 142 glog.Infof("ID: %d", id) | 142 glog.Infof("ID: %d", id) |
| 143 ret = append(ret, c) | 143 ret = append(ret, c) |
| 144 } | 144 } |
| 145 | 145 |
| 146 return ret, nil | 146 return ret, nil |
| 147 } | 147 } |
| 148 | 148 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 373 |
| 374 // Start kicks off a go routine the periodically refreshes the current alerting
clusters. | 374 // Start kicks off a go routine the periodically refreshes the current alerting
clusters. |
| 375 func Start(tileStore types.TileStore, apiKeyFlag string) { | 375 func Start(tileStore types.TileStore, apiKeyFlag string) { |
| 376 apiKey := apiKeyFromFlag(apiKeyFlag) | 376 apiKey := apiKeyFromFlag(apiKeyFlag) |
| 377 go func() { | 377 go func() { |
| 378 for _ = range time.Tick(config.RECLUSTER_DURATION) { | 378 for _ = range time.Tick(config.RECLUSTER_DURATION) { |
| 379 singleStep(tileStore, apiKey) | 379 singleStep(tileStore, apiKey) |
| 380 } | 380 } |
| 381 }() | 381 }() |
| 382 } | 382 } |
| OLD | NEW |