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...