diff --git a/pkg/config/config.go b/pkg/config/config.go index 207c29adfa..8aee13d6c7 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -215,19 +215,20 @@ func (c *Config) TimeoutOrDefault(conn apiconfig.TimeoutType) time.Duration { var timeout time.Duration switch conn { case apiconfig.Endorser: - timeout = myViper.GetDuration("client.endorserConnectionTimeout") + timeout = myViper.GetDuration("client.peer.timeout.connection") + case apiconfig.Query: + timeout = myViper.GetDuration("client.peer.timeout.queryResponse") + case apiconfig.ExecuteTx: + timeout = myViper.GetDuration("client.peer.timeout.executeTxResponse") case apiconfig.EventHub: - timeout = myViper.GetDuration("client.eventServiceConnectionTimeout") + timeout = myViper.GetDuration("client.eventService.timeout.connection") case apiconfig.EventReg: - timeout = myViper.GetDuration("client.eventRegistrationResponseTimeout") + timeout = myViper.GetDuration("client.eventService.timeout.registrationResponse") case apiconfig.OrdererConnection: - timeout = myViper.GetDuration("client.ordererConnectionTimeout") - case apiconfig.Query: - timeout = myViper.GetDuration("client.queryResponseTimeout") - case apiconfig.ExecuteTx: - timeout = myViper.GetDuration("client.executeTxResponseTimeout") + timeout = myViper.GetDuration("client.orderer.timeout.connection") case apiconfig.OrdererResponse: - timeout = myViper.GetDuration("client.ordererResponseTimeout") + timeout = myViper.GetDuration("client.orderer.timeout.response") + } if timeout == 0 { timeout = defaultTimeout diff --git a/pkg/config/config.yaml b/pkg/config/config.yaml index b5bcce2f6e..e5fe5f2181 100755 --- a/pkg/config/config.yaml +++ b/pkg/config/config.yaml @@ -44,7 +44,20 @@ client: logging: level: info - +# Global configuration for peer, event service and orderer timeouts + peer: + timeout: + connection: 3s + queryResponse: 20s + executeTxResponse: 30s + eventService: + timeout: + connection: 3s + registrationResponse: 3s + orderer: + timeout: + connection: 3s + response: 5s # Needed to load users crypto keys and certs. cryptoconfig: @@ -87,21 +100,6 @@ client: #library: "/usr/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so, /usr/lib/softhsm/libsofthsm2.so ,/usr/lib/s390x-linux-gnu/softhsm/libsofthsm2.so, /usr/lib/powerpc64le-linux-gnu/softhsm/libsofthsm2.so, /usr/local/Cellar/softhsm/2.1.0/lib/softhsm/libsofthsm2.so" library: "add BCCSP library here" - #Timeout configs for various connection and response types - endorserConnectionTimeout: 3s - - eventServiceConnectionTimeout: 3s - - ordererConnectionTimeout: 3s - - ordererResponseTimeout: 5s - - eventRegistrationResponseTimeout: 3s - - queryResponseTimeout: 20s - - executeTxResponseTimeout: 30s - # # [Optional]. But most apps would have this section so that channel objects can be constructed diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index b414633cfb..53a7d73380 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -300,13 +300,13 @@ func TestTLSACAConfig(t *testing.T) { } func TestTimeouts(t *testing.T) { - myViper.Set("client.endorserConnectionTimeout", "2s") - myViper.Set("client.eventServiceConnectionTimeout", "2m") - myViper.Set("client.eventRegistrationResponseTimeout", "2h") - myViper.Set("client.ordererConnectionTimeout", "2ms") - myViper.Set("client.queryResponseTimeout", "7h") - myViper.Set("client.executeTxResponseTimeout", "8h") - myViper.Set("client.ordererResponseTimeout", "6s") + myViper.Set("client.peer.timeout.connection", "2s") + myViper.Set("client.eventService.timeout.connection", "2m") + myViper.Set("client.eventService.timeout.registrationResponse", "2h") + myViper.Set("client.orderer.timeout.connection", "2ms") + myViper.Set("client.peer.timeout.queryResponse", "7h") + myViper.Set("client.peer.timeout.executeTxResponse", "8h") + myViper.Set("client.orderer.timeout.response", "6s") t1 := configImpl.TimeoutOrDefault(api.Endorser) if t1 != time.Second*2 { @@ -338,7 +338,7 @@ func TestTimeouts(t *testing.T) { } // Test default - myViper.Set("client.ordererConnectionTimeout", "") + myViper.Set("client.orderer.timeout.connection", "") t1 = configImpl.TimeoutOrDefault(api.OrdererConnection) if t1 != time.Second*5 { t.Fatalf("Timeout not read correctly. Got: %s", t1) diff --git a/test/fixtures/config/config_orgs_test.yaml b/test/fixtures/config/config_orgs_test.yaml index be6c1c2ef8..6a117fc25e 100755 --- a/test/fixtures/config/config_orgs_test.yaml +++ b/test/fixtures/config/config_orgs_test.yaml @@ -44,6 +44,22 @@ client: level: info +# Global configuration for peer, event service and orderer timeouts + peer: + timeout: + connection: 3s + queryResponse: 20s + executeTxResponse: 30s + eventService: + timeout: + connection: 3s + registrationResponse: 3s + orderer: + timeout: + connection: 3s + response: 5s + + # Needed to load users crypto keys and certs. cryptoconfig: path: $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/channel/crypto-config @@ -79,22 +95,6 @@ client: ephemeral: false level: 256 - #Timeout configs for various connection and response types - endorserConnectionTimeout: 3s - - eventServiceConnectionTimeout: 3s - - ordererConnectionTimeout: 3s - - ordererResponseTimeout: 5s - - eventRegistrationResponseTimeout: 3s - - queryResponseTimeout: 20s - - executeTxResponseTimeout: 30s - - # # [Optional]. But most apps would have this section so that channel objects can be constructed # based on the content below. If an app is creating channels, then it likely will not need this diff --git a/test/fixtures/config/config_pkcs11_orgs_test.yaml b/test/fixtures/config/config_pkcs11_orgs_test.yaml index 2759948cd3..606ce4879e 100755 --- a/test/fixtures/config/config_pkcs11_orgs_test.yaml +++ b/test/fixtures/config/config_pkcs11_orgs_test.yaml @@ -44,6 +44,21 @@ client: level: info +# Global configuration for peer, event service and orderer timeouts + peer: + timeout: + connection: 3s + queryResponse: 20s + executeTxResponse: 30s + eventService: + timeout: + connection: 3s + registrationResponse: 3s + orderer: + timeout: + connection: 3s + response: 5s + # Needed to load users crypto keys and certs. cryptoconfig: path: $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/channel/crypto-config @@ -82,21 +97,6 @@ client: label: "ForFabric" library: "/usr/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so, /usr/lib/softhsm/libsofthsm2.so ,/usr/lib/s390x-linux-gnu/softhsm/libsofthsm2.so, /usr/lib/powerpc64le-linux-gnu/softhsm/libsofthsm2.so, /usr/local/Cellar/softhsm/2.1.0/lib/softhsm/libsofthsm2.so" - #Timeout configs for various connection and response types - endorserConnectionTimeout: 3s - - eventServiceConnectionTimeout: 3s - - ordererConnectionTimeout: 3s - - ordererResponseTimeout: 5s - - eventRegistrationResponseTimeout: 3s - - queryResponseTimeout: 20s - - executeTxResponseTimeout: 30s - # # [Optional]. But most apps would have this section so that channel objects can be constructed # based on the content below. If an app is creating channels, then it likely will not need this diff --git a/test/fixtures/config/config_pkcs11_test.yaml b/test/fixtures/config/config_pkcs11_test.yaml index 5dc9a99bd0..c74625edeb 100755 --- a/test/fixtures/config/config_pkcs11_test.yaml +++ b/test/fixtures/config/config_pkcs11_test.yaml @@ -42,6 +42,21 @@ client: logging: level: info +# Global configuration for peer, event service and orderer timeouts + peer: + timeout: + connection: 3s + queryResponse: 20s + executeTxResponse: 30s + eventService: + timeout: + connection: 3s + registrationResponse: 3s + orderer: + timeout: + connection: 3s + response: 5s + # Needed to load users crypto keys and certs. cryptoconfig: path: $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/channel/crypto-config @@ -80,20 +95,6 @@ client: label: "ForFabric" library: "/usr/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so, /usr/lib/softhsm/libsofthsm2.so ,/usr/lib/s390x-linux-gnu/softhsm/libsofthsm2.so, /usr/lib/powerpc64le-linux-gnu/softhsm/libsofthsm2.so, /usr/local/Cellar/softhsm/2.1.0/lib/softhsm/libsofthsm2.so" - #Timeout configs for various connection and response types - endorserConnectionTimeout: 3s - - eventServiceConnectionTimeout: 3s - - ordererConnectionTimeout: 3s - - ordererResponseTimeout: 5s - - eventRegistrationResponseTimeout: 3s - - queryResponseTimeout: 20s - - executeTxResponseTimeout: 30s # # [Optional]. But most apps would have this section so that channel objects can be constructed # based on the content below. If an app is creating channels, then it likely will not need this diff --git a/test/fixtures/config/config_test.yaml b/test/fixtures/config/config_test.yaml index 1ac39fbf14..cb58d9d540 100755 --- a/test/fixtures/config/config_test.yaml +++ b/test/fixtures/config/config_test.yaml @@ -43,6 +43,22 @@ client: logging: level: info +# Global configuration for peer, event service and orderer timeouts + peer: + timeout: + connection: 3s + queryResponse: 20s + executeTxResponse: 30s + eventService: + timeout: + connection: 3s + registrationResponse: 3s + orderer: + timeout: + connection: 3s + response: 5s + + # Needed to load users crypto keys and certs. cryptoconfig: path: $GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/channel/crypto-config @@ -78,20 +94,6 @@ client: ephemeral: false level: 256 - #Timeout configs for various connection and response types - endorserConnectionTimeout: 3s - - eventServiceConnectionTimeout: 3s - - ordererConnectionTimeout: 3s - - ordererResponseTimeout: 5s - - eventRegistrationResponseTimeout: 3s - - queryResponseTimeout: 20s - - executeTxResponseTimeout: 30s # # [Optional]. But most apps would have this section so that channel objects can be constructed # based on the content below. If an app is creating channels, then it likely will not need this