Skip to content

Commit

Permalink
style: define is503 function to follow isABC pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Nov 7, 2024
1 parent 0c9fd97 commit b40f2be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions server/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/Layr-Labs/eigenda-proxy/commitments"
"github.com/Layr-Labs/eigenda-proxy/common"
"github.com/Layr-Labs/eigenda/api"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down Expand Up @@ -44,3 +45,9 @@ func is429(err error) bool {
st, isGRPCError := status.FromError(err)
return isGRPCError && st.Code() == codes.ResourceExhausted
}

// 503 is returned to tell the caller (batcher) to failover to ethda b/c eigenda is temporarily down
func is503(err error) bool {
// TODO: would be cleaner to define a sentinel error in eigenda-core and use that instead
return errors.Is(err, &api.ErrorFailover{})
}
3 changes: 1 addition & 2 deletions server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net/http"

"github.com/Layr-Labs/eigenda-proxy/commitments"
"github.com/Layr-Labs/eigenda/api"
"github.com/gorilla/mux"
)

Expand Down Expand Up @@ -186,7 +185,7 @@ func (svr *Server) handlePostShared(w http.ResponseWriter, r *http.Request, comm
http.Error(w, err.Error(), http.StatusBadRequest)
case is429(err):
http.Error(w, err.Error(), http.StatusTooManyRequests)
case errors.Is(err, &api.ErrorFailover{}):
case is503(err):
// this tells the caller (batcher) to failover to ethda b/c eigenda is temporarily down
http.Error(w, err.Error(), http.StatusServiceUnavailable)
default:
Expand Down

0 comments on commit b40f2be

Please sign in to comment.