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 | |
(:refer-clojure :exclude [get]) | |
(:require | |
[stadig.storage.protocol :as proto])) | |
(defn get | |
[conn bucket key] | |
(when-not bucket | |
(throw (ex-info "Expected bucket" {:type ::bucket-error}))) | |
(proto/get conn bucket key)) |
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)) |
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.protocol | |
(:refer-clojure :exclude [get])) | |
(defprotocol IStorage | |
(get [this bucket key]) | |
(put [this bucket key value]) | |
(delete [this bucket key]) | |
(close [this])) |
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.main | |
(:require | |
[stadig.storage.methods :as storage] | |
[stadig.storage.s3 :as s3])) | |
(defn -main | |
[& args] | |
;; ... initialize some things ... | |
(let [access-key (System/getenv "AWS_ACCESS_KEY_ID") | |
secret-key (System/getenv "AWS_SECRET_ACCESS_KEY") |
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.widget | |
(:require | |
[stadig.storage.methods :as storage])) | |
(defn store-widget | |
[storage-conn widget-name] | |
(storage/put storage-conn | |
"widgets" | |
widget-name | |
(pr-str {:type :widget :name widget-name}))) |
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)) |
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.methods | |
(:refer-clojure :exclude [get])) | |
(defmulti get :backend) | |
(defmulti put :backend) | |
(defmulti delete :backend) | |
(defmulti close :backend) |
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.main | |
(:require | |
[stadig.storage.azure :as storage])) | |
(defn -main | |
[& args] | |
;; ... initialize some things ... | |
(let [shared-key (System/getenv "AZURE_SHARED_KEY") | |
storage-conn (storage/connect shared-key)] | |
(try |
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.widget | |
(:require | |
[stadig.storage.azure :as storage])) | |
(defn store-widget | |
[storage-conn widget-name] | |
(storage/put storage-conn | |
"widgets" | |
widget-name | |
(pr-str {:type :widget :name widget-name}))) |
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.main | |
(:require | |
[stadig.storage.s3 :as storage])) | |
(defn -main | |
[& args] | |
;; ... initialize some things ... | |
(let [access-key (System/getenv "AWS_ACCESS_KEY_ID") | |
secret-key (System/getenv "AWS_SECRET_ACCESS_KEY") | |
storage-conn (storage/connect access-key secret-key)] |