ocular
ocular copied to clipboard
Use improved grpc endpoint retrieval in client construction
Is there any update regarding this issue ?
In order to implement a new feature for Hermes, we need to retrieve a grpc_address
. It looks like get_chain_config()
could provide a grpc address but currently does not. Is there currently a way to retrieve a grpc address ?
@AlianBenabdallah thanks for your question. Currently the client will only attempt to retrieve a healthy gRPC endpoint from the registry when a query is attempted https://github.com/PeggyJV/ocular/blob/26e6aecc832189782117a79b1e48aa22d6a3ccbc/ocular/src/chain/client/query.rs#L96
It sounds like you need to endpoint ahead of time for your own purposes. There are two options that I can immediately think of:
- You can use any of the grpc endoint retrieval methods that exist on the client located in
ocular::chain::client::grpc
, as they are public methods.
// Gets every gRPC endpoint defined for a chain
let grpc = client.get_all_grpc_endpoints().await?;
// Attempts to get only the "healthy" endpoints
let grpc = client.get_grpc_endpoints().await?;
// Return a single, healthy endpoint. This uses the other two methods internally.
let grpc = client.get_random_grpc_endpoint().await?;
A warning though that we have seen inconsistent results with the health check, it apparently needs to be more robust. Sometimes even though a client connection can be established, queries may fail.
- If that option isn't adequate or user-friendly, please suggest your desired API and we can make it happen quickly. This can be as simple as setting a grpc endpoint in the config in the location you suggested, no problem.
The client construction and endpoint management are key features that I feel could improve a lot. I value your feedback! Please let me know what you like and don't like as you use it.