Browse Source

Merge pull request #1337 from tendermint/1296-follow-up

Follow up for /health endpoint
pull/1340/merge
Alexander Simmerl 7 years ago
committed by GitHub
parent
commit
5a51a0ba06
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 1 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +9
    -0
      rpc/client/httpclient.go
  3. +1
    -0
      rpc/client/interface.go
  4. +4
    -0
      rpc/client/localclient.go
  5. +9
    -0
      rpc/client/rpc_test.go
  6. +2
    -1
      rpc/core/health.go

+ 1
- 0
CHANGELOG.md View File

@ -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)


+ 9
- 0
rpc/client/httpclient.go View File

@ -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",


+ 1
- 0
rpc/client/interface.go View File

@ -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


+ 4
- 0
rpc/client/localclient.go View File

@ -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)
}


+ 9
- 0
rpc/client/rpc_test.go View File

@ -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() {


+ 2
- 1
rpc/core/health.go View File

@ -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'


Loading…
Cancel
Save