summaryrefslogtreecommitdiff
path: root/app/fetch.go
diff options
context:
space:
mode:
Diffstat (limited to 'app/fetch.go')
-rw-r--r--app/fetch.go29
1 files changed, 19 insertions, 10 deletions
diff --git a/app/fetch.go b/app/fetch.go
index 82bbb7d..898329d 100644
--- a/app/fetch.go
+++ b/app/fetch.go
@@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"fmt"
+ "strconv"
// "time"
"log"
)
@@ -31,24 +32,32 @@ func healthCheck() {
defer c.Close()
for k, v := range h {
+ if resp, _, err := HttpGet(v.Url); err != nil {
+ fmt.Printf("Error! %v \n", err)
+
+ } else {
+ // fmt.Println("Health check: Okay! ", resp.Status)
+
+ h[k].Status = resp.Status
+ h[k].StatusCode = int64(resp.StatusCode)
+ h[k].Success = true
+ Db.Debug().Save(&h[k])
+ }
+
// save struct in redis as serialized json
// TODO
- j, err := json.Marshal(v)
+ j, err := json.Marshal(h[k])
if err != nil {
log.Println("Error: ", err)
continue
}
+ c.Do("SET", cache_prefix+strconv.Itoa(k), j)
- c.Do("SET", cache_prefix+string(k), j)
+ //c.Do("SET", cache_prefix+strconv.Itoa(k), j)
+ //c.Do("SET", k, j)
- fmt.Println("Json: ", j)
+ // fmt.Printf("Id: %v, Url: %v \n", v.Id, v.Url)
- fmt.Printf("Id: %v, Url: %v \n", v.Id, v.Url)
-
- if resp, _, err := HttpGet(v.Url); err != nil {
- fmt.Printf("Error! %v \n", err)
- } else {
- fmt.Println("Health check: Okay! ", resp.Status)
- }
}
+
}