mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
Add \health
rpc endpoint (#1306)
* Init `\health` rpc endpoint * remove additional info from `\health` rpc endpoint * Cleanup imports * Added time threshold for health check * Update rpc doc * Remove unnecessary checks for blocktime creation lag * Clean up of unnecessary config usage
This commit is contained in:
parent
20b198681b
commit
152290db7e
3
.gitignore
vendored
3
.gitignore
vendored
@ -21,3 +21,6 @@ docs/tools
|
|||||||
|
|
||||||
scripts/wal2json/wal2json
|
scripts/wal2json/wal2json
|
||||||
scripts/cutWALUntil/cutWALUntil
|
scripts/cutWALUntil/cutWALUntil
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
@ -97,6 +97,7 @@ An HTTP Get request to the root RPC endpoint (e.g.
|
|||||||
http://localhost:46657/genesis
|
http://localhost:46657/genesis
|
||||||
http://localhost:46657/net_info
|
http://localhost:46657/net_info
|
||||||
http://localhost:46657/num_unconfirmed_txs
|
http://localhost:46657/num_unconfirmed_txs
|
||||||
|
http://localhost:46657/health
|
||||||
http://localhost:46657/status
|
http://localhost:46657/status
|
||||||
http://localhost:46657/unconfirmed_txs
|
http://localhost:46657/unconfirmed_txs
|
||||||
http://localhost:46657/unsafe_flush_mempool
|
http://localhost:46657/unsafe_flush_mempool
|
||||||
|
@ -81,6 +81,7 @@ Available endpoints:
|
|||||||
/net_info
|
/net_info
|
||||||
/num_unconfirmed_txs
|
/num_unconfirmed_txs
|
||||||
/status
|
/status
|
||||||
|
/health
|
||||||
/unconfirmed_txs
|
/unconfirmed_txs
|
||||||
/unsafe_flush_mempool
|
/unsafe_flush_mempool
|
||||||
/unsafe_stop_cpu_profiler
|
/unsafe_stop_cpu_profiler
|
||||||
|
30
rpc/core/health.go
Normal file
30
rpc/core/health.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get node health. Checks whether new blocks are created.
|
||||||
|
//
|
||||||
|
// ```shell
|
||||||
|
// curl 'localhost:46657/health'
|
||||||
|
// ```
|
||||||
|
//
|
||||||
|
// ```go
|
||||||
|
// client := client.NewHTTP("tcp://0.0.0.0:46657", "/websocket")
|
||||||
|
// result, err := client.Health()
|
||||||
|
// ```
|
||||||
|
//
|
||||||
|
// > The above command returns JSON structured like this:
|
||||||
|
//
|
||||||
|
// ```json
|
||||||
|
// {
|
||||||
|
// "error": "",
|
||||||
|
// "result": {},
|
||||||
|
// "id": "",
|
||||||
|
// "jsonrpc": "2.0"
|
||||||
|
// }
|
||||||
|
// ```
|
||||||
|
func Health() (*ctypes.ResultHealth, error) {
|
||||||
|
return &ctypes.ResultHealth{}, nil
|
||||||
|
}
|
@ -3,10 +3,10 @@ package core
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
crypto "github.com/tendermint/go-crypto"
|
"github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/tendermint/consensus"
|
"github.com/tendermint/tendermint/consensus"
|
||||||
cstypes "github.com/tendermint/tendermint/consensus/types"
|
cstypes "github.com/tendermint/tendermint/consensus/types"
|
||||||
p2p "github.com/tendermint/tendermint/p2p"
|
"github.com/tendermint/tendermint/p2p"
|
||||||
"github.com/tendermint/tendermint/proxy"
|
"github.com/tendermint/tendermint/proxy"
|
||||||
sm "github.com/tendermint/tendermint/state"
|
sm "github.com/tendermint/tendermint/state"
|
||||||
"github.com/tendermint/tendermint/state/txindex"
|
"github.com/tendermint/tendermint/state/txindex"
|
||||||
|
@ -12,6 +12,7 @@ var Routes = map[string]*rpc.RPCFunc{
|
|||||||
"unsubscribe_all": rpc.NewWSRPCFunc(UnsubscribeAll, ""),
|
"unsubscribe_all": rpc.NewWSRPCFunc(UnsubscribeAll, ""),
|
||||||
|
|
||||||
// info API
|
// info API
|
||||||
|
"health": rpc.NewRPCFunc(Health, ""),
|
||||||
"status": rpc.NewRPCFunc(Status, ""),
|
"status": rpc.NewRPCFunc(Status, ""),
|
||||||
"net_info": rpc.NewRPCFunc(NetInfo, ""),
|
"net_info": rpc.NewRPCFunc(NetInfo, ""),
|
||||||
"blockchain": rpc.NewRPCFunc(BlockchainInfo, "minHeight,maxHeight"),
|
"blockchain": rpc.NewRPCFunc(BlockchainInfo, "minHeight,maxHeight"),
|
||||||
|
@ -155,3 +155,5 @@ type ResultEvent struct {
|
|||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
Data types.TMEventData `json:"data"`
|
Data types.TMEventData `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ResultHealth struct{}
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
// json field tags because we always want the JSON
|
// json field tags because we always want the JSON
|
||||||
// representation to be in its canonical form.
|
// representation to be in its canonical form.
|
||||||
type Heartbeat struct {
|
type Heartbeat struct {
|
||||||
ValidatorAddress Address `json:"validator_address"`
|
ValidatorAddress Address `json:"validator_address"`
|
||||||
ValidatorIndex int `json:"validator_index"`
|
ValidatorIndex int `json:"validator_index"`
|
||||||
Height int64 `json:"height"`
|
Height int64 `json:"height"`
|
||||||
Round int `json:"round"`
|
Round int `json:"round"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user