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

feat(blobstorage): add health check, change regular mux for echo, filter changes #16449

Merged
merged 5 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion packages/blobstorage/cmd/flags/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var (
var (
Port = &cli.UintFlag{
Name: "port",
Usage: "Block ID to start indexing from",
Usage: "Port to run server on",
Category: indexerCategory,
EnvVars: []string{"PORT"},
}
Expand Down
11 changes: 9 additions & 2 deletions packages/blobstorage/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,27 @@ func InitFromConfig(ctx context.Context, s *Server, cfg *Config) (err error) {
}

func (s *Server) Start() error {
slog.Info("Server started!")

r := mux.NewRouter()

// Handler functions
r.HandleFunc("/getBlob", s.getBlobHandler).Methods("GET")

r.HandleFunc("/healthz", s.healthzHandler).Methods("GET")

http.Handle("/", r)

slog.Info("starting server on port", "port", s.port)

return http.ListenAndServe(fmt.Sprintf(":%v", s.port), nil)
}

func (s *Server) Close(ctx context.Context) {
}

func (s *Server) healthzHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}

func (s *Server) getBlobHandler(w http.ResponseWriter, r *http.Request) {
blobHashes, ok := r.URL.Query()["blobHash"]
if !ok || len(blobHashes) == 0 {
Expand Down
Loading