All Projects → Taoensso → Faraday

Taoensso / Faraday

Licence: epl-1.0
DynamoDB client for Clojure

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to Faraday

Realworld Dynamodb Lambda
λ serverless backend implementation for RealWorld using AWS DynamoDB + Lambda
Stars: ✭ 185 (-4.15%)
Mutual labels:  aws, dynamodb
Graphql Recipes
A list of GraphQL recipes that, when used with the Amplify CLI, will deploy an entire AWS AppSync GraphQL backend.
Stars: ✭ 137 (-29.02%)
Mutual labels:  aws, dynamodb
Dynein
DynamoDB CLI written in Rust.
Stars: ✭ 126 (-34.72%)
Mutual labels:  aws, dynamodb
Pynamodb
A pythonic interface to Amazon's DynamoDB
Stars: ✭ 1,787 (+825.91%)
Mutual labels:  aws, dynamodb
Awsmobile Cli
CLI experience for Frontend developers in the JavaScript ecosystem.
Stars: ✭ 147 (-23.83%)
Mutual labels:  aws, dynamodb
Full Stack Serverless Cdk
Learn to Build Full-Stack Serverless Apps and APIs using AWS Cloud Development Kit (CDK) in Baby Steps.
Stars: ✭ 122 (-36.79%)
Mutual labels:  aws, dynamodb
Dynamo Easy
DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.
Stars: ✭ 133 (-31.09%)
Mutual labels:  aws, dynamodb
Jedlik
DynamoDB ODM for Node
Stars: ✭ 100 (-48.19%)
Mutual labels:  aws, dynamodb
Dynomite
⚡🦀 🧨 make your rust types fit DynamoDB and visa versa
Stars: ✭ 144 (-25.39%)
Mutual labels:  aws, dynamodb
Serverless Dynamodb Autoscaling
Serverless Plugin for Amazon DynamoDB Auto Scaling configuration.
Stars: ✭ 142 (-26.42%)
Mutual labels:  aws, dynamodb
Dynamodb Json
DynamoDB json util to load and dump strings of Dynamodb json format to python object and vise-versa
Stars: ✭ 114 (-40.93%)
Mutual labels:  aws, dynamodb
Sqs Worker Serverless
Example for SQS Worker in AWS Lambda using Serverless
Stars: ✭ 164 (-15.03%)
Mutual labels:  aws, dynamodb
Npdynamodb
A Node.js Simple Query Builder and ORM for AWS DynamoDB
Stars: ✭ 113 (-41.45%)
Mutual labels:  aws, dynamodb
Flywheel
Object mapper for Amazon's DynamoDB
Stars: ✭ 124 (-35.75%)
Mutual labels:  aws, dynamodb
Autopush Rs
Push Connection Node in Rust
Stars: ✭ 101 (-47.67%)
Mutual labels:  aws, dynamodb
Designing Cloud Native Microservices On Aws
Introduce a fluent way to design cloud native microservices via EventStorming workshop, this is a hands-on workshop. Contains such topics: DDD, Event storming, Specification by example. Including the AWS product : Serverless Lambda , DynamoDB, Fargate, CloudWatch.
Stars: ✭ 131 (-32.12%)
Mutual labels:  aws, dynamodb
Aws Cli Cheatsheet
☁️ AWS CLI + JQ = Make life easier
Stars: ✭ 94 (-51.3%)
Mutual labels:  aws, dynamodb
Diamondb
[WIP] DiamonDB: Rebuild of time series database on AWS.
Stars: ✭ 98 (-49.22%)
Mutual labels:  aws, dynamodb
Dql
A SQL-ish language for DynamoDB
Stars: ✭ 141 (-26.94%)
Mutual labels:  aws, dynamodb
Aws Sdk Perl
A community AWS SDK for Perl Programmers
Stars: ✭ 153 (-20.73%)
Mutual labels:  aws, dynamodb

Faraday, the Clojure DynamoDB client Build Status

  • API Docs
  • Leiningen: [com.taoensso/faraday "1.11.1"]
  • deps.edn: com.taoensso/faraday {:mvn/version "1.11.1"}

DynamoDB makes a great companion for Clojure apps that need a simple, reliable way to persist data, that scales with predictable performance. Faraday is a small, fast and intuitive DynamoDB client library for Clojure, built around the AWS Java SDK and originally adapted from Rotary by James Reeves.

Why Faraday?

  • Small and simple API, with coverage of the most useful DynamoDB features
  • Great performance (zero overhead to the official Java SDK)
  • Uses Nippy for full support of Clojure's rich data types (with compression too)
  • The AWS Java SDK for DynamoDB is awkward and verbose
  • General purpose AWS SDKs for Clojure such as Amazonica or aws-api inherit the awkwardness of the AWS SDK when used to interact with DynamoDB

Getting started

Add Faraday as a dependency to your project and import faraday into your namespace:

(ns my-ns
 (:require [taoensso.faraday :as far]))

Preparing a database

Option 1 - Run a local DynamoDB instance

First thing is to start a DynamoDB Local instance. Once DynamoDB Local is up and running in your terminal, you should see something like:

$ lein dynamodb-local
dynamodb-local: Options {:port 6798, :in-memory? true, :db-path /home/.../.clj-dynamodb-local}
dynamodb-local: Started DynamoDB Local

Then proceed to connecting with your local instance in the next section.

Option 2 - Use DynamoDB in the cloud

Make sure you've got an AWS account - note that there's a free tier with limited DynamoDB storage and read/write throughput. Next you'll need credentials for an IAM user with read/write access to your DynamoDB tables.

Ready?

Connecting

(def client-opts
  {;;; For DynamoDB Local just use some random strings here, otherwise include your
   ;;; production IAM keys:
   :access-key "<AWS_DYNAMODB_ACCESS_KEY>"
   :secret-key "<AWS_DYNAMODB_SECRET_KEY>"

   ;;; You may optionally override the default endpoint if you'd like to use DynamoDB
   ;;; Local or a different AWS Region (Ref. http://goo.gl/YmV80o), etc.:
   ;; :endpoint "http://localhost:6798"                   ; For DynamoDB Local
   ;; :endpoint "http://dynamodb.eu-west-1.amazonaws.com" ; For EU West 1 AWS region

   ;;; You may optionally provide your own (pre-configured) instance of the Amazon
   ;;; DynamoDB client for Faraday functions to use.
   ;; :client (AmazonDynamoDBClientBuilder/defaultClient)
  })

(far/list-tables client-opts)
=> [] ; That's good, we don't have any tables yet :)

Now let's create a table. This is actually one of the more complicated parts of working with DynamoDB since it requires understanding how DynamoDB provisions capacity and how its idiosyncratic primary keys work. We can safely ignore the specifics for now.

(far/create-table client-opts :my-table
  [:id :n]  ; Primary key named "id", (:n => number type)
  {:throughput {:read 1 :write 1} ; Read & write capacity (units/sec)
   :block? true ; Block thread during table creation
   })

;; Wait a minute for the table to be created... got a sandwich handy?

(far/list-tables client-opts)
=> [:my-table] ; There's our new table!

Let's write something to :my-table and then fetch it:

(far/put-item client-opts
    :my-table
    {:id 0 ; Remember that this is our primary (indexed) key
     :name "Steve" :age 22 :data (far/freeze {:vector    [1 2 3]
                                              :set      #{1 2 3}
                                              :rational (/ 22 7)
                                              ;; ... Any Clojure data goodness
                                              })})

(far/get-item client-opts :my-table {:id 0})
=> {:id 0 :name "Steve" :age 22 :data {:vector [1 2 3] ...}}

Remaining API

DynamoDB gives you tons of power including secondary indexes, conditional writes, batch operations, atomic counters, tuneable read consistency and more.

Most of this stuff is controlled through optional arguments and is pretty easy to pick up by seeing the relevant [API] docs:

Tables: list-tables, describe-table, create-table, ensure-table, update-table, delete-table.

Items: get-item, put-item, update-item, delete-item.

Batch items: batch-get-item, batch-write-item.

Querying: query, scan, scan-parallel.

Transactions: transact-write-items, transact-get-items

You can also check out the official AWS DynamoDB documentation, though there's a lot of Java-land complexity that you won't need to deal with when using Faraday. The most useful single doc is probably on the DynamoDB data model and the DynamoDB Best Practices.

Development

This project uses the dynamodb-local lein plugin to manage downloading, starting and stopping an in-memory DynamoDB instance.

To run all the tests locally, run:

lein test-all

If you intend to run tests from a repl, you can start a local DynamoDB instance:

lein dynamodb-local

Contributions

Please see GitHub issues for bugs, ideas, etc. Pull requests welcome. For a general question on usage, try StackOverflow or ask the Faraday users and developers in #faraday at clojurians.slack.com.

License

Distributed under the EPL v1.0 (same as Clojure).

Copyright © 2013-2020 Peter Taoussanis and contributors.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].