-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from Concordium/health-check
Add the healthCheck endpoint to the gRPCClient
- Loading branch information
Showing
4 changed files
with
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { parseEndpoint } from '../shared/util'; | ||
import { createConcordiumClient } from '@concordium/node-sdk'; | ||
import { credentials } from '@grpc/grpc-js'; | ||
|
||
import meow from 'meow'; | ||
|
||
const cli = meow( | ||
` | ||
Usage | ||
$ yarn run-example <path-to-this-file> [options] | ||
Options | ||
--help, Displays this message | ||
--endpoint, -e Specify endpoint of the form "address:port", defaults to localhost:20000 | ||
`, | ||
{ | ||
importMeta: import.meta, | ||
flags: { | ||
endpoint: { | ||
type: 'string', | ||
alias: 'e', | ||
default: 'localhost:20000', | ||
}, | ||
}, | ||
} | ||
); | ||
|
||
const [address, port] = parseEndpoint(cli.flags.endpoint); | ||
|
||
const client = createConcordiumClient( | ||
address, | ||
Number(port), | ||
credentials.createInsecure() | ||
); | ||
|
||
/** | ||
* Queries the node for its health | ||
*/ | ||
(async () => { | ||
// #region documentation-snippet | ||
const check = await client.healthCheck(); | ||
if (check.isHealthy) { | ||
console.log('The node is healthy!'); | ||
} else { | ||
console.log('The node is not healthy'); | ||
console.log('Message: ' + check.message); | ||
} | ||
// #endregion documentation-snippet | ||
})(); |
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