D-Fold is AWS Lambda powered distributed fold for Clojure.
clojure.core.reducers/fold
See more from my presentation at ClojuTre 2016 conference.
Setup your project first (see example project). After that you can use distributed fold in a following way:
(require '[d-fold.core :refer [d-fold]])
(dfold + ((map inc) +) (range 10000) {:reduce-nodes 2 :aws-region "eu-west-1"})
If you make changes to your code update latest code to AWS Lambda environment:
$ lein lambda update example
Check you have your AWS credential setup.
Clone this repo and go to examples
folder. Run:
$ lein lambda install example
This will install AWS Lambda function named d-fold
to region eu-west-1
with IAM role and policies configured.
Run example by starting repl:
$ lein repl
Then run distributed sum function:
(require '[example.core :refer [d-sum]])
(d-sum (range 10000))
This will use two parallel Lambda functions to calculate the result. Note! For the first time it may take some time to run the code because Lambda functions are cold. Further requests should be faster.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |