Plain Functions
An abstraction can be defined and implemented using only plain functions. In this case, the abstraction is not explicit in the code, but is based on using conventional names for definitions:
1Â (ns stadig.storage.s3
2Â Â Â (:refer-clojure :exclude [get])
3Â Â Â (:require
4Â Â Â Â [aws.sdk.s3 :as s3]))
5
6Â (defn connect
7Â Â Â [access-key secret-key]
8Â Â Â {:access-key access-key :secret-key secret-key})
9
10Â (defn get
11Â Â Â [conn bucket key]
12Â Â Â (when-not bucket
13Â Â Â Â Â (throw (ex-info "Expected bucket" {:type ::bucket-error})))
14Â Â Â (s3/get-object conn bucket key))
15
16Â (defn put
17Â Â Â [conn bucket key value]
18Â Â Â (when-not bucket
19Â Â Â Â Â (throw (ex-info "Expected bucket" {:type ::bucket-error})))
20Â Â Â (s3/put-object conn bucket key value))
21
22Â (defn...