feat(config): Make gRPC http connections configurable #832
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Make characteristics of the gRPC connections, such as keep alives and timeouts, configurable via
ClientBuilder
.EndpointConfig
struct with configuration values for thetonic
Endpoint
instances that will be created laterendpoint_config
method onClientBuilder
to override the default configurationClientBuilder
publicManagedNetworkBuilder
enum which is accepted byClientBuilder
instead ofManagedNetwork
- allowing construction ofManagedNetwork
to be delayed untilClientBuilder::build
is called, sinceManagedNetwork
requiresEndpointConfig
All of the
Client
constructor methods now returnResult<Self, _>
instead of simplySelf
- this is due to the delayed parsing of the keys ofHashMap<String, AccountId>
intoHostPort
, and could be avoided if usage ofHashMap<String, AccountId>
were replaced withHashMap<HostPort, AccountId>
(orHashMap<HostPort, EntityId>
).Related issue(s):
#833
#834
Notes for reviewer:
The node endpoint configuration capability is applicable to any combination of network nodes - both the preconfigured networks (mainnet, testnet, and previewnet), and custom networks. It would be possible, but inconvenient, to add a means to set endpoint configuration on either a
Client
instance or on one of theClient
constructor methods.Instead, this PR makes
ClientBuilder
public and adds a method to the builder to override the default endpoint configuration.Tonic's
Endpoint
instances are setup whenNodeConnection
creates a channel:hedera-sdk-rust/src/client/network/mod.rs
Lines 587 to 598 in 40cc835
Each
NodeConnection
is created in eitherNetworkData::from_addresses
orNetworkData::with_address_book
Constructor call sites
NetworkData::from_addresses
is typically called during initial creation of aClient
via a constructor method onClient
Example:
hedera-sdk-rust/src/client/mod.rs
Lines 285 to 290 in 40cc835
Dynamic network update call sites
NetworkData::with_address_book
is a part of the dynamic network update process where a client can periodically alter its preferred choice of nodes, though it can also be called viaClient::set_network_from_address_book
on a client instance.Checklist