Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

Commit

Permalink
Fixed conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbalazs93 committed Feb 27, 2017
2 parents 19c1989 + de6b7b5 commit cf7289c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
fthealth "github.com/Financial-Times/go-fthealth/v1a"
oldhttphandlers "github.com/Financial-Times/http-handlers-go/httphandlers"
"github.com/Financial-Times/service-status-go/httphandlers"
"github.com/Financial-Times/service-status-go/gtg"
"github.com/Sirupsen/logrus"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
Expand Down Expand Up @@ -121,7 +122,7 @@ func main() {
h := setupServiceHandler(sc, metricsHandler, contentHandler)
appLogger.ServiceStartedEvent(*serviceName, sc.asMap())
metricsHandler.OutputMetricsIfRequired(*graphiteTCPAddress, *graphitePrefix, *logMetrics)
err := http.ListenAndServe(":"+*appPort, h)
err := http.ListenAndServe(":" + *appPort, h)
if err != nil {
logrus.Fatalf("Unable to start server: %v", err)
}
Expand All @@ -135,6 +136,8 @@ func setupServiceHandler(sc ServiceConfig, metricsHandler Metrics, contentHandle
oldhttphandlers.TransactionAwareRequestLoggingHandler(logrus.StandardLogger(), contentHandler))})
r.Path(httphandlers.BuildInfoPath).HandlerFunc(httphandlers.BuildInfoHandler)
r.Path(httphandlers.PingPath).HandlerFunc(httphandlers.PingHandler)
gtgHandler := httphandlers.NewGoodToGoHandler(gtg.StatusChecker(sc.gtgCheck))
r.Path(httphandlers.GTGPath).HandlerFunc(gtgHandler)
r.Path("/__health").Handler(handlers.MethodHandler{"GET": http.HandlerFunc(fthealth.Handler(sc.serviceName, serviceDescription, sc.nativeContentSourceCheck(), sc.transformerServiceCheck()))})
r.Path("/__metrics").Handler(handlers.MethodHandler{"GET": http.HandlerFunc(metricsHttpEndpoint)})
return r
Expand Down
17 changes: 16 additions & 1 deletion healthchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
fthealth "github.com/Financial-Times/go-fthealth/v1a"
"github.com/Financial-Times/service-status-go/gtg"
"net/http"
)

Expand Down Expand Up @@ -33,10 +34,24 @@ func (sc *ServiceConfig) transformerServiceCheck() fthealth.Check {
}
}

func (sc *ServiceConfig) gtgCheck() gtg.Status {
msg, err := checkServiceAvailability(sc.sourceAppName, sc.sourceAppHealthUri, sc.sourceAppAuth)
if err != nil {
return gtg.Status{GoodToGo:false, Message:msg}
}

msg, err = checkServiceAvailability(sc.transformAppName, sc.transformAppHealthUri, "")
if err != nil {
return gtg.Status{GoodToGo:false, Message:msg}
}

return gtg.Status{GoodToGo:true}
}

func checkServiceAvailability(serviceName string, healthUri string, auth string) (string, error) {
req, err := http.NewRequest("GET", healthUri, nil)
if auth != "" {
req.Header.Set("Authorization", "Basic "+auth)
req.Header.Set("Authorization", "Basic " + auth)
}
resp, err := client.Do(req)
if err != nil {
Expand Down

0 comments on commit cf7289c

Please sign in to comment.