Skip to content

Commit cfc84fc

Browse files
authored
allow to configure http client timeout (#20)
1 parent ada7050 commit cfc84fc

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

cloudstack/cloudstack.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@ func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds int64) {
358358
cs.timeout = timeoutInSeconds
359359
}
360360

361+
// Sets timeout when using sync api calls. Default is 60 seconds
362+
func (cs *CloudStackClient) Timeout(timeout time.Duration) {
363+
cs.client.Timeout = timeout
364+
}
365+
361366
// Set any default options that would be added to all API calls that support it.
362367
func (cs *CloudStackClient) DefaultOptions(options ...OptionFunc) {
363368
if options != nil {

generate/generate.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ func (as *allServices) GeneralCode() ([]byte, error) {
390390
pn(" cs.timeout = timeoutInSeconds")
391391
pn("}")
392392
pn("")
393+
pn("// Sets timeout when using sync api calls. Default is 60 seconds")
394+
pn("func (cs *CloudStackClient) Timeout(timeout time.Duration) {")
395+
pn(" cs.client.Timeout = timeout")
396+
pn("}")
397+
pn("")
393398
pn("// Set any default options that would be added to all API calls that support it.")
394399
pn("func (cs *CloudStackClient) DefaultOptions(options ...OptionFunc) {")
395400
pn(" if options != nil {")

0 commit comments

Comments
 (0)