Skip to content

Instantly share code, notes, and snippets.

@pjstadig
Created February 25, 2022 14:20
Show Gist options
  • Save pjstadig/0de0ded71cf50c656475465a02a6fea2 to your computer and use it in GitHub Desktop.
Save pjstadig/0de0ded71cf50c656475465a02a6fea2 to your computer and use it in GitHub Desktop.
Protocol + client + multimethod
(ns stadig.storage
(:refer-clojure :exclude [get])
(:require
[stadig.storage.azure]
[stadig.storage.cloudfiles]
[stadig.storage.protocol :as proto]
[stadig.storage.s3]))
(defn connect
[options]
(proto/connect options))
(defn get
[conn bucket key]
(when-not bucket
(throw (ex-info "Expected bucket" {:type ::bucket-error})))
(proto/get conn bucket key))
(defn put
[conn bucket key value]
(when-not bucket
(throw (ex-info "Expected bucket" {:type ::bucket-error})))
(proto/put conn bucket key value))
(defn delete
[conn bucket key]
(when-not bucket
(throw (ex-info "Expected bucket" {:type ::bucket-error})))
(proto/delete conn bucket key))
(defn close
[conn]
(proto/close conn))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment