implementing the status endpoint

This commit is contained in:
Gustavo Massaneiro
2022-01-01 19:51:37 -03:00
parent 5c128893bc
commit 04b195dd00
2 changed files with 17 additions and 1 deletions

View File

@@ -1,9 +1,11 @@
package controllers
import (
"mizuserver/pkg/api"
"net/http"
"github.com/gin-gonic/gin"
"github.com/up9inc/mizu/shared"
)
type ServiceMapController struct{}
@@ -13,7 +15,14 @@ func NewServiceMapController() *ServiceMapController {
}
func (s *ServiceMapController) Status(c *gin.Context) {
c.JSON(http.StatusNotImplemented, nil)
serviceMap := api.GetServiceMapInstance()
status := &shared.ServiceMapStatus{
Status: "enabled",
EntriesProcessedCount: serviceMap.GetEntriesProcessedCount(),
NodeCount: serviceMap.GetNodesCount(),
EdgeCount: serviceMap.GetEdgesCount(),
}
c.JSON(http.StatusOK, status)
}
func (s *ServiceMapController) Get(c *gin.Context) {

View File

@@ -69,6 +69,13 @@ type WebSocketTapConfigMessage struct {
TapTargets []v1.Pod `json:"pods"`
}
type ServiceMapStatus struct {
Status string `json:"status"`
EntriesProcessedCount int `json:"entriesProcessedCount"`
NodeCount int `json:"nodeCount"`
EdgeCount int `json:"edgeCount"`
}
type TapperStatus struct {
TapperName string `json:"tapperName"`
NodeName string `json:"nodeName"`