What is the best way to go about specifying several peers that client application could contact for them to start a transaction on a channel when using fabric-gateway?
Examples I've found in docs rely on connection to a single peer, which I find problematic, since if it goes offline the application won't work. I thought about distributing requests manually application-side, but I am not sure it is the intended way to go about it.
// Create a Gateway connection for a specific client identity
gw, err := client.Connect(
id,
client.WithSign(sign),
client.WithClientConnection(clientConnection),
// Default timeouts for different gRPC calls
client.WithEvaluateTimeout(5*time.Second),
client.WithEndorseTimeout(15*time.Second),
client.WithSubmitTimeout(5*time.Second),
client.WithCommitStatusTimeout(1*time.Minute),
)
It might help to think of your client application connecting to the Gateway service as similar to a Web browser connecting to a specific Website. There is a single logical connection to a single logical endpoint. That does not mean that your client application (or Web browser) must stop working if a single Gateway peer (or Web server) goes offline.
This section from workshop material in the Fabric samples repository discusses some of the approaches that can be taken to ensure high availability:
To summarise:
The Gateway service within the peer uses the discovery service internally to help select the best peers for transaction invocations, and to manage fail-over during the transaction flow. Your client application should only be using Gateway peers from a trusted organisation (ideally exposed on a single endpoint address) so should have no need to interact with the discovery service to discover other network peers.