Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataApi] Add Service Availability Handler #276

Merged
merged 26 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion disperser/cmd/dataapi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type Config struct {

BLSOperatorStateRetrieverAddr string
EigenDAServiceManagerAddr string

DisperserHostname string
ChurnerHostname string
}

func NewConfig(ctx *cli.Context) Config {
Expand All @@ -54,8 +57,10 @@ func NewConfig(ctx *cli.Context) Config {
AllowOrigins: ctx.GlobalStringSlice(flags.AllowOriginsFlag.Name),
MetricsConfig: dataapi.MetricsConfig{
HTTPPort: ctx.GlobalString(flags.MetricsHTTPPort.Name),
EnableMetrics: ctx.GlobalBool(flags.EnableMetrics.Name),
EnableMetrics: ctx.GlobalBool(flags.EnableMetricsFlag.Name),
},
DisperserHostname: ctx.GlobalString(flags.DisperserHostnameFlag.Name),
ChurnerHostname: ctx.GlobalString(flags.ChurnerHostnameFlag.Name),
}
return config
}
22 changes: 20 additions & 2 deletions disperser/cmd/dataapi/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,28 @@ var (
EnvVar: common.PrefixEnvVar(envVarPrefix, "ALLOW_ORIGINS"),
Required: true,
}
EnableMetrics = cli.BoolFlag{
EnableMetricsFlag = cli.BoolFlag{
Name: common.PrefixFlag(FlagPrefix, "enable-metrics"),
Usage: "start metrics server",
Required: true,
EnvVar: common.PrefixEnvVar(envVarPrefix, "ENABLE_METRICS"),
}
// EigenDA Disperser and Churner Hostnames to check Server Availability
// ex:
// disperser-goerli.eigenda.eigenops.xyz,
// churner-goerli.eigenda.eigenops.xyz
DisperserHostnameFlag = cli.StringFlag{
Name: common.PrefixFlag(FlagPrefix, "eigenda-disperser-hostname"),
Usage: "HostName of EigenDA Disperser",
Required: true,
EnvVar: common.PrefixEnvVar(envVarPrefix, "EIGENDA_DISPERSER_HOSTNAME"),
}
ChurnerHostnameFlag = cli.StringFlag{
Name: common.PrefixFlag(FlagPrefix, "eigenda-churner-hostname"),
Usage: "HostName of EigenDA Churner",
Required: true,
EnvVar: common.PrefixEnvVar(envVarPrefix, "EIGENDA_CHURNER_HOSTNAME"),
}
/* Optional Flags*/
MetricsHTTPPort = cli.StringFlag{
Name: common.PrefixFlag(FlagPrefix, "metrics-http-port"),
Expand All @@ -125,7 +141,9 @@ var requiredFlags = []cli.Flag{
PrometheusServerSecretFlag,
PrometheusMetricsClusterLabelFlag,
AllowOriginsFlag,
EnableMetrics,
EnableMetricsFlag,
DisperserHostnameFlag,
ChurnerHostnameFlag,
}

var optionalFlags = []cli.Flag{
Expand Down
33 changes: 30 additions & 3 deletions disperser/cmd/dataapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"log"
"os"
"os/signal"
"syscall"

"github.com/Layr-Labs/eigenda/common/aws/dynamodb"
"github.com/Layr-Labs/eigenda/common/aws/s3"
Expand Down Expand Up @@ -90,9 +92,11 @@ func RunDataApi(ctx *cli.Context) error {
metrics = dataapi.NewMetrics(blobMetadataStore, config.MetricsConfig.HTTPPort, logger)
server = dataapi.NewServer(
dataapi.Config{
ServerMode: config.ServerMode,
SocketAddr: config.SocketAddr,
AllowOrigins: config.AllowOrigins,
ServerMode: config.ServerMode,
SocketAddr: config.SocketAddr,
AllowOrigins: config.AllowOrigins,
DisperserHostname: config.DisperserHostname,
ChurnerHostname: config.ChurnerHostname,
},
sharedStorage,
promClient,
Expand All @@ -101,6 +105,8 @@ func RunDataApi(ctx *cli.Context) error {
chainState,
logger,
metrics,
nil,
nil,
)
)

Expand All @@ -111,5 +117,26 @@ func RunDataApi(ctx *cli.Context) error {
logger.Info("Enabled metrics for Data Access API", "socket", httpSocket)
}

// Setup channel to listen for termination signals
quit := make(chan os.Signal, 1)
// catch SIGINT (Ctrl+C) and SIGTERM (e.g., from `kill`)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)

// Run server in a separate goroutine so that it doesn't block.
go func() {
if err := server.Start(); err != nil {
logger.Fatalf("Failed to start server: %v", err)
}
}()

// Block until a signal is received.
<-quit
logger.Info("Shutting down server...")
err = server.Shutdown()

if err != nil {
logger.Errorf("Failed to shutdown server: %v", err)
}

return server.Start()
}
8 changes: 5 additions & 3 deletions disperser/dataapi/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package dataapi

type Config struct {
SocketAddr string
ServerMode string
AllowOrigins []string
SocketAddr string
ServerMode string
AllowOrigins []string
DisperserHostname string
ChurnerHostname string
}
62 changes: 62 additions & 0 deletions disperser/dataapi/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,43 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/eigenda/service-availability": {
"get": {
"produces": [
"application/json"
],
"tags": [
"ServiceAvailability"
],
"summary": "Get status of public 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 @@ -542,6 +579,31 @@ const docTemplate = `{
}
}
},
"dataapi.ServiceAvailability": {
"type": "object",
"properties": {
"service_name": {
"type": "string"
},
"service_status": {
"type": "string"
}
}
},
"dataapi.ServiceAvailabilityResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/dataapi.ServiceAvailability"
}
},
"meta": {
"$ref": "#/definitions/dataapi.Meta"
}
}
},
"dataapi.Throughput": {
"type": "object",
"properties": {
Expand Down
62 changes: 62 additions & 0 deletions disperser/dataapi/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,43 @@
"version": "1"
},
"paths": {
"/eigenda/service-availability": {
"get": {
"produces": [
"application/json"
],
"tags": [
"ServiceAvailability"
],
"summary": "Get status of public 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 @@ -538,6 +575,31 @@
}
}
},
"dataapi.ServiceAvailability": {
"type": "object",
"properties": {
"service_name": {
"type": "string"
},
"service_status": {
"type": "string"
}
}
},
"dataapi.ServiceAvailabilityResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/dataapi.ServiceAvailability"
}
},
"meta": {
"$ref": "#/definitions/dataapi.Meta"
}
}
},
"dataapi.Throughput": {
"type": "object",
"properties": {
Expand Down
40 changes: 40 additions & 0 deletions disperser/dataapi/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ definitions:
meta:
$ref: '#/definitions/dataapi.Meta'
type: object
dataapi.ServiceAvailability:
properties:
service_name:
type: string
service_status:
type: string
type: object
dataapi.ServiceAvailabilityResponse:
properties:
data:
items:
$ref: '#/definitions/dataapi.ServiceAvailability'
type: array
meta:
$ref: '#/definitions/dataapi.Meta'
type: object
dataapi.Throughput:
properties:
throughput:
Expand Down Expand Up @@ -194,6 +210,30 @@ 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 public EigenDA services.
tags:
- ServiceAvailability
/feed/blobs:
get:
parameters:
Expand Down
Loading
Loading