Description:
Make characteristics of the gRPC connections, such as keep alives and timeouts, configurable via ClientBuilder.
Add a new EndpointConfig struct with configuration values for the tonicEndpoint instances that will be created later
Add a new endpoint_config method on ClientBuilder to override the default configuration
Make ClientBuilder public
Add a new private ManagedNetworkBuilder enum which is accepted by ClientBuilder instead of ManagedNetwork - allowing construction of ManagedNetwork to be delayed until ClientBuilder::build is called, since ManagedNetwork requires EndpointConfig
All of the Client constructor methods now return Result<Self, _> instead of simply Self - this is due to the delayed parsing of the keys of HashMap<String, AccountId> into HostPort, and could be avoided if usage of HashMap<String, AccountId> were replaced with HashMap<HostPort, AccountId> (or HashMap<HostPort, EntityId>).
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 the Client 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 when NodeConnection creates a channel:
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 via Client::set_network_from_address_book on a client instance.
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):
https://github.com/hashgraph/hedera-sdk-rust/issues/833 https://github.com/hashgraph/hedera-sdk-rust/issues/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:https://github.com/hashgraph/hedera-sdk-rust/blob/40cc835628347772ca1cc71b9d860e2a4c3b1214/src/client/network/mod.rs#L587-L598
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: https://github.com/hashgraph/hedera-sdk-rust/blob/40cc835628347772ca1cc71b9d860e2a4c3b1214/src/client/mod.rs#L285-L290
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