taoensso / faraday

Amazon DynamoDB client for Clojure
https://www.taoensso.com/faraday
Eclipse Public License 1.0
238 stars 84 forks source link

Allow custom client to be used by Faraday fns #133

Closed joelittlejohn closed 4 years ago

joelittlejohn commented 4 years ago

This change allows client-opts to include a :client key, where the value is a pre-configured instance of AmazonDynamoDBClient (or AmazonDynamoDBStreamsClient for stream fns). Faraday functions will use this client instance rather than creating and configuring their own.

Using the :client key allows applications to customise the client instance used by Faraday, which is particularly useful when integrating Amazon DynamoDB Accelerator (DAX) or Amazon X-Ray.

laurio commented 1 year ago

is there a sample code about how to use it with Amazon DynamoDB Accelerator (DAX)? i tried to following:

(far/get-item {:client (-> (AmazonDaxClientBuilder/standard)
                           (.withEndpointConfiguration
                            (AwsClientBuilder$EndpointConfiguration. "http://localhost:8111/" "us-west-2"))
                           (.build))}
              "items-table"
              {:id "id"})

but it returns the following error:

Execution error (ClassCastException) at taoensso.faraday/get-item (faraday.clj:950).
class com.amazonaws.services.dax.AmazonDaxClient cannot be cast to class
com.amazonaws.services.dynamodbv2.AmazonDynamoDB (com.amazonaws.services.dax.AmazonDaxClient and
com.amazonaws.services.dynamodbv2.AmazonDynamoDB are in unnamed module of loader 'app')