Created
February 25, 2022 14:19
-
-
Save pjstadig/93e9234089eb89bae5fb2788c4a1c136 to your computer and use it in GitHub Desktop.
Protocol + client + multimethod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns stadig.storage.s3 | |
(:require | |
[aws.sdk.s3 :as s3] | |
[stadig.storage.protocol :as proto])) | |
(defrecord S3Storage | |
[access-key secret-key] | |
proto/IStorage | |
(get [this bucket key] | |
(s3/get-object this bucket key)) | |
(put [this bucket key value] | |
(s3/put-object this bucket key value)) | |
(delete [this bucket key] | |
(s3/delete-object this bucket key)) | |
(close [this])) | |
(defmethod proto/connect :s3 | |
[{:keys [access-key secret-key] :as options}] | |
(->S3Storage access-key secret-key)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment