Initial ORION Telemetry service
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package config
|
||||
|
||||
import "os"
|
||||
|
||||
type Config struct {
|
||||
Port string
|
||||
}
|
||||
|
||||
func Load() Config {
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "18080"
|
||||
}
|
||||
|
||||
return Config{
|
||||
Port: port,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/lyra/orion-telemetry/internal/version"
|
||||
)
|
||||
|
||||
func Health(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"service": version.Service,
|
||||
"status": "healthy",
|
||||
})
|
||||
}
|
||||
|
||||
func Version(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"service": version.Service,
|
||||
"version": version.Version,
|
||||
"commit": version.Commit,
|
||||
"buildTime": version.BuildTime,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
func NewRouter() *gin.Engine {
|
||||
r := gin.Default()
|
||||
|
||||
r.GET("/health", Health)
|
||||
r.GET("/version", Version)
|
||||
r.GET("/metrics", gin.WrapH(promhttp.Handler()))
|
||||
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package version
|
||||
|
||||
var (
|
||||
Service = "orion-telemetry"
|
||||
Version = "dev"
|
||||
Commit = "unknown"
|
||||
BuildTime = "unknown"
|
||||
)
|
||||
Reference in New Issue
Block a user