add ready and healthy probe endpoints

This commit is contained in:
Markus Muellner
2022-07-01 10:24:23 +02:00
committed by Benj Fassbind
parent 352f4e8772
commit 2020ca9971
8 changed files with 163 additions and 46 deletions
+18
View File
@@ -8,6 +8,7 @@ import (
"sort"
"strconv"
"strings"
"sync/atomic"
"github.com/aptly-dev/aptly/aptly"
"github.com/aptly-dev/aptly/deb"
@@ -27,6 +28,23 @@ func apiVersion(c *gin.Context) {
c.JSON(200, gin.H{"Version": aptly.Version})
}
// GET /api/ready
func apiReady(isReady *atomic.Value) func(*gin.Context) {
return func(c *gin.Context) {
if isReady == nil || !isReady.Load().(bool) {
c.JSON(503, gin.H{"Status": "Aptly is unavailable"})
return
}
c.JSON(200, gin.H{"Status": "Aptly is ready"})
}
}
// GET /api/healthy
func apiHealthy(c *gin.Context) {
c.JSON(200, gin.H{"Status": "Aptly is healthy"})
}
type dbRequestKind int
const (