From b11c26cc1c36552e8d88e0bad6d1d950537ade14 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 19 Mar 2018 19:53:28 +0300 Subject: [PATCH 1/3] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d528c95eb..6635d1e1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ IMPROVEMENTS: FEATURES: - [config] added the `--p2p.private_peer_ids` flag and `PrivatePeerIDs` config variable (see config for description) +- [rpc] added `/health` endpoint, which returns empty result for now ## 0.16.0 (February 20th, 2017) From 830bb72d6f6fc731e0fc16b8b2b12f9780341cfc Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 19 Mar 2018 19:53:50 +0300 Subject: [PATCH 2/3] add Health method to clients Refs #1296 --- rpc/client/httpclient.go | 9 +++++++++ rpc/client/interface.go | 1 + rpc/client/localclient.go | 4 ++++ rpc/client/rpc_test.go | 9 +++++++++ 4 files changed, 23 insertions(+) diff --git a/rpc/client/httpclient.go b/rpc/client/httpclient.go index bc6cf759e..83d77f317 100644 --- a/rpc/client/httpclient.go +++ b/rpc/client/httpclient.go @@ -122,6 +122,15 @@ func (c *HTTP) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) { return result, nil } +func (c *HTTP) Health() (*ctypes.ResultHealth, error) { + result := new(ctypes.ResultHealth) + _, err := c.rpc.Call("health", map[string]interface{}{}, result) + if err != nil { + return nil, errors.Wrap(err, "Health") + } + return result, nil +} + func (c *HTTP) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { result := new(ctypes.ResultBlockchainInfo) _, err := c.rpc.Call("blockchain", diff --git a/rpc/client/interface.go b/rpc/client/interface.go index 6715b64b5..7a065291e 100644 --- a/rpc/client/interface.go +++ b/rpc/client/interface.go @@ -83,6 +83,7 @@ type Client interface { type NetworkClient interface { NetInfo() (*ctypes.ResultNetInfo, error) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) + Health() (*ctypes.ResultHealth, error) } // EventsClient is reactive, you can subscribe to any message, given the proper diff --git a/rpc/client/localclient.go b/rpc/client/localclient.go index be989ee1c..7e2f8fedc 100644 --- a/rpc/client/localclient.go +++ b/rpc/client/localclient.go @@ -84,6 +84,10 @@ func (Local) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) { return core.DumpConsensusState() } +func (Local) Health() (*ctypes.ResultHealth, error) { + return core.Health() +} + func (Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) { return core.UnsafeDialSeeds(seeds) } diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index c582e6640..f23ba6160 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -78,6 +78,15 @@ func TestDumpConsensusState(t *testing.T) { } } +func TestHealth(t *testing.T) { + for i, c := range GetClients() { + nc, ok := c.(client.NetworkClient) + require.True(t, ok, "%d", i) + _, err := nc.Health() + require.Nil(t, err, "%d: %+v", i, err) + } +} + func TestGenesisAndValidators(t *testing.T) { for i, c := range GetClients() { From 460599ef75539dff5f3cb5352254426e98283532 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 19 Mar 2018 19:54:11 +0300 Subject: [PATCH 3/3] fix comment --- rpc/core/health.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpc/core/health.go b/rpc/core/health.go index dd71b4a91..ab2ceb16b 100644 --- a/rpc/core/health.go +++ b/rpc/core/health.go @@ -4,7 +4,8 @@ import ( ctypes "github.com/tendermint/tendermint/rpc/core/types" ) -// Get node health. Checks whether new blocks are created. +// Get node health. Returns empty result (200 OK) on success, no response - in +// case of an error. // // ```shell // curl 'localhost:46657/health'