Skip to content

Instantly share code, notes, and snippets.

@pjstadig
Created February 25, 2022 14:19
Show Gist options
  • Save pjstadig/93e9234089eb89bae5fb2788c4a1c136 to your computer and use it in GitHub Desktop.
Save pjstadig/93e9234089eb89bae5fb2788c4a1c136 to your computer and use it in GitHub Desktop.
Protocol + client + multimethod
(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