feat(proxyd): impl proxyd_healthz method (#8658)

This commit is contained in:
felipe 2023-12-18 10:58:18 -08:00 committed by GitHub
parent ca17102998
commit b1522ace51
2 changed files with 13 additions and 2 deletions

@ -17,6 +17,7 @@ import (
"sync"
"time"
sw "github.com/ethereum-optimism/optimism/proxyd/pkg/avg-sliding-window"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
@ -24,8 +25,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/xaionaro-go/weightedshuffle"
"golang.org/x/sync/semaphore"
sw "github.com/ethereum-optimism/optimism/proxyd/pkg/avg-sliding-window"
)
const (
@ -285,6 +284,8 @@ type indexedReqRes struct {
res *RPCRes
}
const proxydHealthzMethod = "proxyd_healthz"
const ConsensusGetReceiptsMethod = "consensus_getReceipts"
const ReceiptsTargetDebugGetRawReceipts = "debug_getRawReceipts"

@ -435,6 +435,16 @@ func (s *Server) handleBatchRPC(ctx context.Context, reqs []json.RawMessage, isL
continue
}
// Simple health check
if len(reqs) == 1 && parsedReq.Method == proxydHealthzMethod {
res := &RPCRes{
ID: parsedReq.ID,
JSONRPC: JSONRPCVersion,
Result: "OK",
}
return []*RPCRes{res}, false, "", nil
}
if err := ValidateRPCReq(parsedReq); err != nil {
RecordRPCError(ctx, BackendProxyd, MethodUnknown, err)
responses[i] = NewRPCErrorRes(nil, err)