-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(observability):add ready&health check api for k8s (#938)
Co-authored-by: georgehao <georgehao@users.noreply.github.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
- Loading branch information
1 parent
4d3ff66
commit 0730e91
Showing
45 changed files
with
361 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package controller | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"gorm.io/gorm" | ||
|
||
"bridge-history-api/internal/types" | ||
"bridge-history-api/utils" | ||
) | ||
|
||
// HealthCheckController is health check API | ||
type HealthCheckController struct { | ||
db *gorm.DB | ||
} | ||
|
||
// NewHealthCheckController returns an HealthCheckController instance | ||
func NewHealthCheckController(db *gorm.DB) *HealthCheckController { | ||
return &HealthCheckController{ | ||
db: db, | ||
} | ||
} | ||
|
||
// HealthCheck the api controller for coordinator health check | ||
func (a *HealthCheckController) HealthCheck(c *gin.Context) { | ||
if _, err := utils.Ping(a.db); err != nil { | ||
types.RenderFatal(c, err) | ||
return | ||
} | ||
types.RenderSuccess(c, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package controller | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
|
||
"bridge-history-api/internal/types" | ||
) | ||
|
||
// ReadyController ready API | ||
type ReadyController struct { | ||
} | ||
|
||
// NewReadyController returns an ReadyController instance | ||
func NewReadyController() *ReadyController { | ||
return &ReadyController{} | ||
} | ||
|
||
// Ready the api controller for coordinator ready | ||
func (r *ReadyController) Ready(c *gin.Context) { | ||
types.RenderSuccess(c, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
common/metrics/middleware.go → common/observability/middleware.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package observability | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"gorm.io/gorm" | ||
|
||
"scroll-tech/common/database" | ||
"scroll-tech/common/types" | ||
) | ||
|
||
// ProbesController probe check controller | ||
type ProbesController struct { | ||
db *gorm.DB | ||
} | ||
|
||
// NewProbesController returns an ProbesController instance | ||
func NewProbesController(db *gorm.DB) *ProbesController { | ||
return &ProbesController{ | ||
db: db, | ||
} | ||
} | ||
|
||
// HealthCheck the api controller for health check | ||
func (a *ProbesController) HealthCheck(c *gin.Context) { | ||
if _, err := database.Ping(a.db); err != nil { | ||
types.RenderFatal(c, err) | ||
return | ||
} | ||
types.RenderSuccess(c, nil) | ||
} | ||
|
||
// Ready the api controller for ready check | ||
func (a *ProbesController) Ready(c *gin.Context) { | ||
types.RenderSuccess(c, nil) | ||
} |
Oops, something went wrong.