Skip to content
Permalink
Browse files

Fixing import cycle and golint complains

  • Loading branch information...
Depado committed Apr 1, 2016
1 parent 54c104d commit 9acb9e1059bbe944aec514fb438b53551f2eccb1
Showing with 9 additions and 6 deletions.
  1. +1 −1 main.go
  2. +2 −4 models/service.go
  3. +4 −0 views/api.go
  4. +2 −1 views/views.go
@@ -23,7 +23,7 @@ func main() {
log.Fatal(err)
}
// Starting monitoring of services
go models.All.Monitor()
go models.All.Monitor(conf.C.UpdateInterval)

// Gin initialization
if !conf.C.Debug {
@@ -8,8 +8,6 @@ import (
"net/http"
"strings"
"time"

"github.com/Depado/gomonit/conf"
)

// All represents all the services
@@ -140,8 +138,8 @@ func (s *Service) Check() {
type Services []*Service

// Monitor allows to monitor Services every interval delay
func (ss Services) Monitor() {
tc := time.NewTicker(conf.C.UpdateInterval)
func (ss Services) Monitor(interval time.Duration) {
tc := time.NewTicker(interval)
for {
for _, s := range ss {
go s.Check()
@@ -8,6 +8,7 @@ import (
"github.com/Depado/gomonit/models"
)

// Status gets only the status of all the services (HTTP status code)
func Status(c *gin.Context) {
resp := gin.H{}
for _, s := range models.All {
@@ -16,10 +17,13 @@ func Status(c *gin.Context) {
c.JSON(200, resp)
}

// DumpAll dumps all the data and returns them as JSON
func DumpAll(c *gin.Context) {
c.JSON(200, models.All)
}

// DumpOwn is the same as DumpAll but only for services marked as "own" in the
// configuration
func DumpOwn(c *gin.Context) {
resp := models.Services{}
for _, s := range models.All {
@@ -8,7 +8,8 @@ import (
"github.com/Depado/gomonit/models"
)

func index(c *gin.Context) {
// Index is the main route
func Index(c *gin.Context) {
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"all": models.All,
})

0 comments on commit 9acb9e1

Please sign in to comment.
You can’t perform that action at this time.