Merge branch 'wtsi/14110-c-d-s-limit-slurm-concurrency' refs #14110
[arvados.git] / sdk / go / arvadosclient / arvadosclient.go
index 4cfda94581518fd9360ebc4f3268e231893797c7..e3a9f4ae8d892ea03f379e7dad3ded4a6dc951fc 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
 /* Simple Arvados Go SDK for communicating with API server. */
 
 package arvadosclient
@@ -118,6 +122,9 @@ type ArvadosClient struct {
 
        // Number of retries
        Retries int
+
+       // X-Request-Id for outgoing requests
+       RequestID string
 }
 
 var CertFiles = []string{
@@ -166,8 +173,11 @@ func New(c *arvados.Client) (*ArvadosClient, error) {
                ApiServer:   c.APIHost,
                ApiToken:    c.AuthToken,
                ApiInsecure: c.Insecure,
-               Client: &http.Client{Transport: &http.Transport{
-                       TLSClientConfig: MakeTLSConfig(c.Insecure)}},
+               Client: &http.Client{
+                       Timeout: 5 * time.Minute,
+                       Transport: &http.Transport{
+                               TLSClientConfig: MakeTLSConfig(c.Insecure)},
+               },
                External:          false,
                Retries:           2,
                KeepServiceURIs:   c.KeepServiceURIs,
@@ -262,6 +272,9 @@ func (c *ArvadosClient) CallRaw(method string, resourceType string, uuid string,
 
                // Add api token header
                req.Header.Add("Authorization", fmt.Sprintf("OAuth2 %s", c.ApiToken))
+               if c.RequestID != "" {
+                       req.Header.Add("X-Request-Id", c.RequestID)
+               }
                if c.External {
                        req.Header.Add("X-External-Client", "1")
                }