Skip to content

Added proxy support#18

Open
cesarpinera wants to merge 5 commits intoweavejester:masterfrom
cesarpinera:proxy-support
Open

Added proxy support#18
cesarpinera wants to merge 5 commits intoweavejester:masterfrom
cesarpinera:proxy-support

Conversation

@cesarpinera
Copy link

I'm adding proxy support to the creation of the DynamoDB client.

In the credential map two new keys :proxy-host and :proxy-port can be specified. If they exist, a ClientConfiguration instance is added to the constructor of the AmazonDynamoDB object.

E.g.:

{:access-key "AAA" :secret-key "ZZZ" :proxy-host "proxy-us.intel.com" :proxy-port 911}

@weavejester
Copy link
Owner

You could write it a little more compactly like:

(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-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)))

Since:

(AmazonDynamoDBClient. aws-creds)

Is equivalent to:

(AmazonDynamoDBClient. aws-creds (ClientConfiguration.))

Added proxy-host and proxy-port keys to the credential map and to the
db-client* fn.
@cesarpinera
Copy link
Author

Excellent suggestion. I made the changes. I do believe it's important to test for both proxy-host and proxy-port, otherwise ClientConfiguration will be incomplete if one of the values is missing.

@weavejester
Copy link
Owner

Why is it a bad thing if ClientConfiguration is incomplete? It's generally better to fail noisily, and I'd prefer an exception over a silent failure.

@cesarpinera
Copy link
Author

Got it. I made proxy-host and proxy-port independent of each other.

@weavejester
Copy link
Owner

Could you squash your commits? Then I'll merge.

@cesarpinera
Copy link
Author

It took me a litte while to find out how to squash commits that have already been pushed. I hope I did it right. Let me know.

@weavejester
Copy link
Owner

I'm afraid you haven't done it right. Run the following command:

git rebase -i master

This will open up an editor with an interactive rebase. Use the editor to change all but one commit to be squashed. Once you've done that, you should end up with just one commit ahead of master. You can use git log to check.

In order to push the commits, run:

git push -f

The -f part will force the push to overwrite the old.

@cesarpinera
Copy link
Author

I'm sorry but I cannot seem to find a way to do that. It appears like the commits have already been squashed and pushed to the branch.

If you prefer, I can create a new branch, put a single commit there and then create a new pull request from it.

Thank you for being this patient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants