Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Clojure Polymorphism

You're reading from   Clojure Polymorphism Leverage Clojure's polymorphic tools to develop your applications

Arrow left icon
Product type Paperback
Published in Nov 2019
Publisher
ISBN-13 9781838982362
Length 56 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Paul Stadig Paul Stadig
Author Profile Icon Paul Stadig
Paul Stadig
Arrow right icon
View More author details
Toc

Plain Functions + Client Namespace

A variation on using plain functions would be to return a map that contains the implementation functions:

1 (ns stadig.storage.s3

2   (:refer-clojure :exclude [get])

3   (:require

4    [aws.sdk.s3 :as s3]))

5

6 (defn get

7   [conn bucket key]

8   (s3/get-object conn bucket key))

9

10 (defn put

11   [conn bucket key value]

12   (s3/put-object conn bucket key value))

13

14 (defn delete

15   [conn bucket key]

16   (s3/delete-object conn bucket key))

17

18 (defn close

19   [conn])

20

21 (defn connect

22   [access-key secret-key]

23   (let [conn {:access-key access-key :secret-key secret-key}]

24     {:get (partial get conn)

25      :put (partial put conn)

26      :delete (partial delete conn)

27 ...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime