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.EndpointConfigstruct with configuration values for thetonicEndpointinstances that will be created laterendpoint_configmethod onClientBuilderto override the default configurationClientBuilderpublicManagedNetworkBuilderenum which is accepted byClientBuilderinstead ofManagedNetwork- allowing construction ofManagedNetworkto be delayed untilClientBuilder::buildis called, sinceManagedNetworkrequiresEndpointConfigAll of the
Clientconstructor 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
Clientinstance or on one of theClientconstructor methods.Instead, this PR makes
ClientBuilderpublic and adds a method to the builder to override the default endpoint configuration.Tonic's
Endpointinstances are setup whenNodeConnectioncreates a channel:https://github.com/hashgraph/hedera-sdk-rust/blob/40cc835628347772ca1cc71b9d860e2a4c3b1214/src/client/network/mod.rs#L587-L598
Each
NodeConnectionis created in eitherNetworkData::from_addressesorNetworkData::with_address_bookConstructor call sites
NetworkData::from_addressesis typically called during initial creation of aClientvia a constructor method onClientExample: https://github.com/hashgraph/hedera-sdk-rust/blob/40cc835628347772ca1cc71b9d860e2a4c3b1214/src/client/mod.rs#L285-L290
Dynamic network update call sites
NetworkData::with_address_bookis 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_bookon a client instance.Checklist