From d55e1960bf4a88614934abec4a454e1a28a416e2 Mon Sep 17 00:00:00 2001 From: cpinera Date: Fri, 5 Apr 2013 15:26:07 -0700 Subject: [PATCH 1/4] Addded proxy configuration to the credential map and to the creation of the dynamodb client --- src/rotary/client.clj | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/rotary/client.clj b/src/rotary/client.clj index c7afc6a..5fa244d 100644 --- a/src/rotary/client.clj +++ b/src/rotary/client.clj @@ -3,7 +3,8 @@ (:use [clojure.algo.generic.functor :only (fmap)] [clojure.core.incubator :only (-?>>)]) (:require [clojure.string :as str]) - (:import com.amazonaws.auth.BasicAWSCredentials + (:import com.amazonaws.ClientConfiguration + com.amazonaws.auth.BasicAWSCredentials com.amazonaws.services.dynamodb.AmazonDynamoDBClient [com.amazonaws.services.dynamodb.model AttributeValue @@ -38,12 +39,19 @@ (defn- db-client* "Get a AmazonDynamoDBClient instance for the supplied credentials." - [cred] - (let [aws-creds (BasicAWSCredentials. (:access-key cred) (:secret-key cred)) - client (AmazonDynamoDBClient. aws-creds)] - (when-let [endpoint (:endpoint cred)] - (.setEndpoint client endpoint)) - client)) + [{:keys [access-key secret-key endpoint proxy-host proxy-port]}] + (let [aws-creds (BasicAWSCredentials. access-key secret-key) + client-configuration (when (and proxy-host proxy-port) (ClientConfiguration.))] + (when client-configuration + (doto client-configuration + (.setProxyHost proxy-host) + (.setProxyPort proxy-port))) + (let [client (if client-configuration + (AmazonDynamoDBClient. aws-creds client-configuration) + (AmazonDynamoDBClient. aws-creds))] + (when endpoint + (.setEndpoint client endpoint)) + client))) (def db-client (memoize db-client*)) From 3df448fe9fc3e88fb26caeb533aa133d54b0f080 Mon Sep 17 00:00:00 2001 From: cpinera Date: Fri, 5 Apr 2013 22:01:44 -0700 Subject: [PATCH 2/4] Added proxy support Added proxy-host and proxy-port keys to the credential map and to the db-client* fn. --- src/rotary/client.clj | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/rotary/client.clj b/src/rotary/client.clj index 5fa244d..77a3b13 100644 --- a/src/rotary/client.clj +++ b/src/rotary/client.clj @@ -40,17 +40,14 @@ (defn- db-client* "Get a AmazonDynamoDBClient instance for the supplied credentials." [{:keys [access-key secret-key endpoint proxy-host proxy-port]}] - (let [aws-creds (BasicAWSCredentials. access-key secret-key) - client-configuration (when (and proxy-host proxy-port) (ClientConfiguration.))] - (when client-configuration - (doto client-configuration + (let [aws-creds (BasicAWSCredentials. access-key secret-key) + client-config (ClientConfiguration.)] + (when (and proxy-host proxy-port) + (doto client-config (.setProxyHost proxy-host) (.setProxyPort proxy-port))) - (let [client (if client-configuration - (AmazonDynamoDBClient. aws-creds client-configuration) - (AmazonDynamoDBClient. aws-creds))] - (when endpoint - (.setEndpoint client endpoint)) + (let [client (AmazonDynamoDBClient. aws-creds client-config)] + (when endpoint (.setEndpoint client endpoint)) client))) (def db-client From b7bfd60295ab25e4e3d9686e52d6305a3e90acab Mon Sep 17 00:00:00 2001 From: cpinera Date: Sat, 6 Apr 2013 17:45:41 -0700 Subject: [PATCH 3/4] Proxy-host and Proxy-port are now set independently of each other. --- src/rotary/client.clj | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rotary/client.clj b/src/rotary/client.clj index 77a3b13..0e8d6c3 100644 --- a/src/rotary/client.clj +++ b/src/rotary/client.clj @@ -42,10 +42,8 @@ [{:keys [access-key secret-key endpoint proxy-host proxy-port]}] (let [aws-creds (BasicAWSCredentials. access-key secret-key) client-config (ClientConfiguration.)] - (when (and proxy-host proxy-port) - (doto client-config - (.setProxyHost proxy-host) - (.setProxyPort proxy-port))) + (when proxy-host (.setProxyHost client-config proxy-host)) + (when proxy-port (.setProxyPort client-config proxy-port)) (let [client (AmazonDynamoDBClient. aws-creds client-config)] (when endpoint (.setEndpoint client endpoint)) client))) From 2b9dec32ff9b60187bee23fb606f8aebcf9b30c4 Mon Sep 17 00:00:00 2001 From: cpinera Date: Fri, 5 Apr 2013 15:26:07 -0700 Subject: [PATCH 4/4] Addded proxy configuration to the credential map and to the creation of the dynamodb client --- src/rotary/client.clj | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/rotary/client.clj b/src/rotary/client.clj index c7afc6a..0e8d6c3 100644 --- a/src/rotary/client.clj +++ b/src/rotary/client.clj @@ -3,7 +3,8 @@ (:use [clojure.algo.generic.functor :only (fmap)] [clojure.core.incubator :only (-?>>)]) (:require [clojure.string :as str]) - (:import com.amazonaws.auth.BasicAWSCredentials + (:import com.amazonaws.ClientConfiguration + com.amazonaws.auth.BasicAWSCredentials com.amazonaws.services.dynamodb.AmazonDynamoDBClient [com.amazonaws.services.dynamodb.model AttributeValue @@ -38,12 +39,14 @@ (defn- db-client* "Get a AmazonDynamoDBClient instance for the supplied credentials." - [cred] - (let [aws-creds (BasicAWSCredentials. (:access-key cred) (:secret-key cred)) - client (AmazonDynamoDBClient. aws-creds)] - (when-let [endpoint (:endpoint cred)] - (.setEndpoint client endpoint)) - client)) + [{:keys [access-key secret-key endpoint proxy-host proxy-port]}] + (let [aws-creds (BasicAWSCredentials. access-key secret-key) + client-config (ClientConfiguration.)] + (when proxy-host (.setProxyHost client-config proxy-host)) + (when proxy-port (.setProxyPort client-config proxy-port)) + (let [client (AmazonDynamoDBClient. aws-creds client-config)] + (when endpoint (.setEndpoint client endpoint)) + client))) (def db-client (memoize db-client*))