Skip to content

Commit

Permalink
[FAB-6385] Go SDK timeouts config restructure
Browse files Browse the repository at this point in the history
Change-Id: I14f2e772eea9e72170ee976f436fba3b895c4c45
Signed-off-by: Sudesh Shetty <sudesh.shetty@securekey.com>
  • Loading branch information
sudeshrshetty committed Oct 3, 2017
1 parent e34811c commit a1cb9c9
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 92 deletions.
19 changes: 10 additions & 9 deletions pkg/config/config.go
Expand Up @@ -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
Expand Down
30 changes: 14 additions & 16 deletions pkg/config/config.yaml
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions pkg/config/config_test.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
32 changes: 16 additions & 16 deletions test/fixtures/config/config_orgs_test.yaml
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions test/fixtures/config/config_pkcs11_orgs_test.yaml
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
29 changes: 15 additions & 14 deletions test/fixtures/config/config_pkcs11_test.yaml
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
30 changes: 16 additions & 14 deletions test/fixtures/config/config_test.yaml
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a1cb9c9

Please sign in to comment.