Skip to content

Commit

Permalink
[DataApi] Remove GetServiceAvailability API (Layr-Labs#470)
Browse files Browse the repository at this point in the history
Co-authored-by: Siddharth More <Siddhi More>
  • Loading branch information
siddimore authored Apr 12, 2024
1 parent f443f22 commit 5e6a82e
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 475 deletions.
39 changes: 1 addition & 38 deletions disperser/dataapi/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,6 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/eigenda/service-availability": {
"get": {
"produces": [
"application/json"
],
"tags": [
"ServiceAvailability"
],
"summary": "Get status of EigenDA services.",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dataapi.ServiceAvailabilityResponse"
}
},
"400": {
"description": "error: Bad request",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"404": {
"description": "error: Not found",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"500": {
"description": "error: Server error",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
}
}
}
},
"/feed/blobs": {
"get": {
"produces": [
Expand Down Expand Up @@ -377,7 +340,7 @@ const docTemplate = `{
},
{
"type": "string",
"description": "End time (UTC) to query for operators nonsigning percentage",
"description": "End time (2006-01-02T15:04:05Z) to query for operators nonsigning percentage [default: now]",
"name": "end",
"in": "query"
}
Expand Down
39 changes: 1 addition & 38 deletions disperser/dataapi/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,6 @@
"version": "1"
},
"paths": {
"/eigenda/service-availability": {
"get": {
"produces": [
"application/json"
],
"tags": [
"ServiceAvailability"
],
"summary": "Get status of EigenDA services.",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dataapi.ServiceAvailabilityResponse"
}
},
"400": {
"description": "error: Bad request",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"404": {
"description": "error: Not found",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"500": {
"description": "error: Server error",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
}
}
}
},
"/feed/blobs": {
"get": {
"produces": [
Expand Down Expand Up @@ -373,7 +336,7 @@
},
{
"type": "string",
"description": "End time (UTC) to query for operators nonsigning percentage",
"description": "End time (2006-01-02T15:04:05Z) to query for operators nonsigning percentage [default: now]",
"name": "end",
"in": "query"
}
Expand Down
27 changes: 2 additions & 25 deletions disperser/dataapi/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,30 +225,6 @@ info:
title: EigenDA Data Access API
version: "1"
paths:
/eigenda/service-availability:
get:
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dataapi.ServiceAvailabilityResponse'
"400":
description: 'error: Bad request'
schema:
$ref: '#/definitions/dataapi.ErrorResponse'
"404":
description: 'error: Not found'
schema:
$ref: '#/definitions/dataapi.ErrorResponse'
"500":
description: 'error: Server error'
schema:
$ref: '#/definitions/dataapi.ErrorResponse'
summary: Get status of EigenDA services.
tags:
- ServiceAvailability
/feed/blobs:
get:
parameters:
Expand Down Expand Up @@ -456,7 +432,8 @@ paths:
in: query
name: interval
type: integer
- description: End time (UTC) to query for operators nonsigning percentage
- description: 'End time (2006-01-02T15:04:05Z) to query for operators nonsigning
percentage [default: now]'
in: query
name: end
type: string
Expand Down
67 changes: 0 additions & 67 deletions disperser/dataapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ func (s *server) Start() error {
{
operatorsInfo.GET("/deregistered-operators", s.FetchDeregisteredOperators)
}
serviceAvailability := v1.Group("/eigenda")
{
serviceAvailability.GET("/service-availability", s.GetEigenDAServiceAvailability)
}
metrics := v1.Group("/metrics")
{
metrics.GET("/", s.FetchMetricsHandler)
Expand Down Expand Up @@ -556,69 +552,6 @@ func (s *server) FetchDeregisteredOperators(c *gin.Context) {
})
}

// GetEigenDAServiceAvailability godoc
//
// @Summary Get status of EigenDA services.
// @Tags ServiceAvailability
// @Produce json
// @Success 200 {object} ServiceAvailabilityResponse
// @Failure 400 {object} ErrorResponse "error: Bad request"
// @Failure 404 {object} ErrorResponse "error: Not found"
// @Failure 500 {object} ErrorResponse "error: Server error"
// @Router /eigenda/service-availability [get]
func (s *server) GetEigenDAServiceAvailability(c *gin.Context) {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(f float64) {
s.metrics.ObserveLatency("GetEigenDAServiceAvailability", f*1000) // make milliseconds
}))
defer timer.ObserveDuration()

// Get query parameters to filter services
serviceName := c.DefaultQuery("service-name", "") // If not specified, default to return all services

// If service name is not specified, return all services
services := []string{}

if serviceName == "disperser" {
services = append(services, "Disperser")
} else if serviceName == "churner" {
services = append(services, "Churner")
} else if serviceName == "" {
services = append(services, "Disperser", "Churner")
}
s.logger.Info("Getting service availability for", "services", strings.Join(services, ", "))

availabilityStatuses, err := s.getServiceAvailability(c.Request.Context(), services)
if err != nil {
s.metrics.IncrementFailedRequestNum("GetEigenDAServiceAvailability")
errorResponse(c, err)
return
}

s.metrics.IncrementSuccessfulRequestNum("GetEigenDAServiceAvailability")

// Set the status code to 503 if any of the services are not serving
availabilityStatus := http.StatusOK
for _, status := range availabilityStatuses {
if status.ServiceStatus == "NOT_SERVING" {
availabilityStatus = http.StatusServiceUnavailable
break
}

if status.ServiceStatus == "UNKNOWN" {
availabilityStatus = http.StatusInternalServerError
break
}

}

c.JSON(availabilityStatus, ServiceAvailabilityResponse{
Meta: Meta{
Size: len(availabilityStatuses),
},
Data: availabilityStatuses,
})
}

// FetchDisperserServiceAvailability godoc
//
// @Summary Get status of EigenDA Disperser service.
Expand Down
Loading

0 comments on commit 5e6a82e

Please sign in to comment.