Created
February 25, 2022 14:02
-
-
Save pjstadig/7a66cfd553b93661529f1cc6430274e2 to your computer and use it in GitHub Desktop.
Multimethods
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.methods :as methods])) | |
(defmethod methods/get :s3 | |
[this bucket key] | |
(when-not bucket | |
(throw (ex-info "Expected bucket" {:type ::bucket-error}))) | |
(s3/get-object this bucket key)) | |
(defmethod methods/put :s3 | |
[this bucket key value] | |
(when-not bucket | |
(throw (ex-info "Expected bucket" {:type ::bucket-error}))) | |
(s3/put-object this bucket key value)) | |
(defmethod methods/delete :s3 | |
[this bucket key] | |
(when-not bucket | |
(throw (ex-info "Expected bucket" {:type ::bucket-error}))) | |
(s3/delete-object this bucket key)) | |
(defmethod methods/close :s3 | |
[this]) | |
(defn connect | |
[access-key secret-key] | |
{:backend :s3 :access-key access-key :secret-key secret-key}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment