This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented statedb status in /health endpoint (#967)
* implemented statedb status * added new field to swagger.yml * added comments for exported types and functions related to the statedb health checking
- Loading branch information
Showing
8 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package checkers | ||
|
||
import ( | ||
"github.com/dimiro1/health" | ||
"github.com/hermeznetwork/hermez-node/db/statedb" | ||
) | ||
|
||
// StateDBChecker struct for state db connection checker | ||
type StateDBChecker struct { | ||
stateDB *statedb.StateDB | ||
} | ||
|
||
// NewStateDBChecker init state db connection checker | ||
func NewStateDBChecker(sdb *statedb.StateDB) StateDBChecker { | ||
return StateDBChecker{ | ||
stateDB: sdb, | ||
} | ||
} | ||
|
||
// Check state db health | ||
func (sdb StateDBChecker) Check() health.Health { | ||
h := health.NewHealth() | ||
|
||
batchNum, err := sdb.stateDB.LastGetCurrentBatch() | ||
if err != nil { | ||
h.Down().AddInfo("error", err.Error()) | ||
return h | ||
} | ||
|
||
root, err := sdb.stateDB.LastMTGetRoot() | ||
if err != nil { | ||
h.Down().AddInfo("error", err.Error()) | ||
return h | ||
} | ||
|
||
h.Up(). | ||
AddInfo("batchNum", batchNum). | ||
AddInfo("root", root) | ||
|
||
return h | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters