This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack-go.git


The following commit(s) were added to refs/heads/main by this push:
     new cfc84fc  allow to configure http client timeout (#20)
cfc84fc is described below

commit cfc84fc7f3226aa327a4c2621981f087310ee274
Author: Xavier MARCELET <[email protected]>
AuthorDate: Thu Nov 18 11:49:59 2021 +0100

    allow to configure http client timeout (#20)
---
 cloudstack/cloudstack.go | 5 +++++
 generate/generate.go     | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/cloudstack/cloudstack.go b/cloudstack/cloudstack.go
index 47671e7..0b6896a 100644
--- a/cloudstack/cloudstack.go
+++ b/cloudstack/cloudstack.go
@@ -358,6 +358,11 @@ func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds 
int64) {
        cs.timeout = timeoutInSeconds
 }
 
+// Sets timeout when using sync api calls. Default is 60 seconds
+func (cs *CloudStackClient) Timeout(timeout time.Duration) {
+       cs.client.Timeout = timeout
+}
+
 // Set any default options that would be added to all API calls that support 
it.
 func (cs *CloudStackClient) DefaultOptions(options ...OptionFunc) {
        if options != nil {
diff --git a/generate/generate.go b/generate/generate.go
index 79692ad..89ce4b5 100644
--- a/generate/generate.go
+++ b/generate/generate.go
@@ -390,6 +390,11 @@ func (as *allServices) GeneralCode() ([]byte, error) {
        pn("    cs.timeout = timeoutInSeconds")
        pn("}")
        pn("")
+       pn("// Sets timeout when using sync api calls. Default is 60 seconds")
+       pn("func (cs *CloudStackClient) Timeout(timeout time.Duration) {")
+       pn("    cs.client.Timeout = timeout")
+       pn("}")
+       pn("")
        pn("// Set any default options that would be added to all API calls 
that support it.")
        pn("func (cs *CloudStackClient) DefaultOptions(options ...OptionFunc) 
{")
        pn("    if options != nil {")

Reply via email to