[ARVADOS] updated: 536b5affd9ec66f0c7cc27d1b4a06e04190d4b29

git at public.curoverse.com git at public.curoverse.com
Tue Jun 10 14:03:12 EDT 2014


Summary of changes:
 sdk/go/src/arvados.org/keepclient/keepclient.go | 14 ++++++------
 sdk/go/src/arvados.org/keepclient/support.go    |  4 +---
 sdk/go/src/arvados.org/sdk/sdk.go               | 30 ++++++++++++++++---------
 3 files changed, 28 insertions(+), 20 deletions(-)

       via  536b5affd9ec66f0c7cc27d1b4a06e04190d4b29 (commit)
      from  906022feeb3347b95962eddd2e9d0ca10d92742a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 536b5affd9ec66f0c7cc27d1b4a06e04190d4b29
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Jun 10 14:00:25 2014 -0400

    2826: Added documentation to ArvadosClient struct.  ArvadosClient methods take
    a copy, not a pointer to denote that they are free of side effects.  Added a
    separate Client object to KeepClient struct that can be configured separately
    from API server client.  Removed obsolete defer comment.

diff --git a/sdk/go/src/arvados.org/keepclient/keepclient.go b/sdk/go/src/arvados.org/keepclient/keepclient.go
index 32c765d..d43a215 100644
--- a/sdk/go/src/arvados.org/keepclient/keepclient.go
+++ b/sdk/go/src/arvados.org/keepclient/keepclient.go
@@ -38,17 +38,17 @@ type KeepClient struct {
 	Using_proxy   bool
 	service_roots *[]string
 	lock          sync.Mutex
+	Client        *http.Client
 }
 
-// Create a new KeepClient, initialized with standard Arvados environment
-// variables ARVADOS_API_HOST, ARVADOS_API_TOKEN, and (optionally)
-// ARVADOS_API_HOST_INSECURE.  This will contact the API server to discover
-// Keep servers.
+// Create a new KeepClient.  This will contact the API server to discover Keep
+// servers.
 func MakeKeepClient(arv *sdk.ArvadosClient) (kc KeepClient, err error) {
 	kc = KeepClient{
 		Arvados:       arv,
 		Want_replicas: 2,
-		Using_proxy:   false}
+		Using_proxy:   false,
+		Client:        &http.Client{Transport: &http.Transport{}}}
 
 	err = (&kc).DiscoverKeepServers()
 
@@ -152,7 +152,7 @@ func (this KeepClient) AuthorizedGet(hash string,
 		req.Header.Add("Authorization", fmt.Sprintf("OAuth2 %s", this.Arvados.ApiToken))
 
 		var resp *http.Response
-		if resp, err = this.Arvados.Client.Do(req); err != nil {
+		if resp, err = this.Client.Do(req); err != nil {
 			continue
 		}
 
@@ -194,7 +194,7 @@ func (this KeepClient) AuthorizedAsk(hash string, signature string,
 		req.Header.Add("Authorization", fmt.Sprintf("OAuth2 %s", this.Arvados.ApiToken))
 
 		var resp *http.Response
-		if resp, err = this.Arvados.Client.Do(req); err != nil {
+		if resp, err = this.Client.Do(req); err != nil {
 			continue
 		}
 
diff --git a/sdk/go/src/arvados.org/keepclient/support.go b/sdk/go/src/arvados.org/keepclient/support.go
index 5d6d2b2..f3e47f9 100644
--- a/sdk/go/src/arvados.org/keepclient/support.go
+++ b/sdk/go/src/arvados.org/keepclient/support.go
@@ -41,8 +41,6 @@ func (this *KeepClient) DiscoverKeepServers() error {
 		}
 	}
 
-	// 'defer' is a stack, so it will drain the Body before closing it.
-
 	listed := make(map[string]bool)
 	service_roots := make([]string, 0, len(m.Items))
 
@@ -156,7 +154,7 @@ func (this KeepClient) uploadToKeepServer(host string, hash string, body io.Read
 	req.Body = body
 
 	var resp *http.Response
-	if resp, err = this.Arvados.Client.Do(req); err != nil {
+	if resp, err = this.Client.Do(req); err != nil {
 		upload_status <- uploadStatus{err, url, 0, 0, ""}
 		body.Close()
 		return
diff --git a/sdk/go/src/arvados.org/sdk/sdk.go b/sdk/go/src/arvados.org/sdk/sdk.go
index 1931826..9f1880f 100644
--- a/sdk/go/src/arvados.org/sdk/sdk.go
+++ b/sdk/go/src/arvados.org/sdk/sdk.go
@@ -27,11 +27,21 @@ type Dict map[string]interface{}
 
 // Information about how to contact the Arvados server
 type ArvadosClient struct {
-	ApiServer   string
-	ApiToken    string
+	// Arvados API server, form "host:port"
+	ApiServer string
+
+	// Arvados API token for authentication
+	ApiToken string
+
+	// Whether to require a valid SSL certificate or not
 	ApiInsecure bool
-	Client      *http.Client
-	External    bool
+
+	// Client object shared by client requests.  Supports HTTP KeepAlive.
+	Client *http.Client
+
+	// If true, sets the X-External-Client header to indicate
+	// the client is outside the cluster.
+	External bool
 }
 
 // Create a new KeepClient, initialized with standard Arvados environment
@@ -70,7 +80,7 @@ func MakeArvadosClient() (kc ArvadosClient, err error) {
 // return
 //   reader - the body reader, or nil if there was an error
 //   err - error accessing the resource, or nil if no error
-func (this *ArvadosClient) CallRaw(method string, resource string, uuid string, action string, parameters Dict) (reader io.ReadCloser, err error) {
+func (this ArvadosClient) CallRaw(method string, resource string, uuid string, action string, parameters Dict) (reader io.ReadCloser, err error) {
 	var req *http.Request
 
 	u := url.URL{
@@ -156,7 +166,7 @@ func (this *ArvadosClient) CallRaw(method string, resource string, uuid string,
 //   output - a map or annotated struct which is a legal target for encoding/json/Decoder
 // return
 //   err - error accessing the resource, or nil if no error
-func (this *ArvadosClient) Call(method string, resource string, uuid string, action string, parameters Dict, output interface{}) (err error) {
+func (this ArvadosClient) Call(method string, resource string, uuid string, action string, parameters Dict, output interface{}) (err error) {
 	var reader io.ReadCloser
 	reader, err = this.CallRaw(method, resource, uuid, action, parameters)
 	if reader != nil {
@@ -182,7 +192,7 @@ func (this *ArvadosClient) Call(method string, resource string, uuid string, act
 //   output - a map or annotated struct which is a legal target for encoding/json/Decoder
 // return
 //   err - error accessing the resource, or nil if no error
-func (this *ArvadosClient) Create(resource string, parameters Dict, output interface{}) (err error) {
+func (this ArvadosClient) Create(resource string, parameters Dict, output interface{}) (err error) {
 	return this.Call("POST", resource, "", "", parameters, output)
 }
 
@@ -194,7 +204,7 @@ func (this *ArvadosClient) Create(resource string, parameters Dict, output inter
 //   output - a map or annotated struct which is a legal target for encoding/json/Decoder
 // return
 //   err - error accessing the resource, or nil if no error
-func (this *ArvadosClient) Delete(resource string, uuid string, parameters Dict, output interface{}) (err error) {
+func (this ArvadosClient) Delete(resource string, uuid string, parameters Dict, output interface{}) (err error) {
 	return this.Call("DELETE", resource, uuid, "", parameters, output)
 }
 
@@ -206,7 +216,7 @@ func (this *ArvadosClient) Delete(resource string, uuid string, parameters Dict,
 //   output - a map or annotated struct which is a legal target for encoding/json/Decoder
 // return
 //   err - error accessing the resource, or nil if no error
-func (this *ArvadosClient) Update(resource string, uuid string, parameters Dict, output interface{}) (err error) {
+func (this ArvadosClient) Update(resource string, uuid string, parameters Dict, output interface{}) (err error) {
 	return this.Call("PUT", resource, uuid, "", parameters, output)
 }
 
@@ -217,6 +227,6 @@ func (this *ArvadosClient) Update(resource string, uuid string, parameters Dict,
 //   output - a map or annotated struct which is a legal target for encoding/json/Decoder
 // return
 //   err - error accessing the resource, or nil if no error
-func (this *ArvadosClient) List(resource string, parameters Dict, output interface{}) (err error) {
+func (this ArvadosClient) List(resource string, parameters Dict, output interface{}) (err error) {
 	return this.Call("GET", resource, "", "", parameters, output)
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list