Skip to content

Instantly share code, notes, and snippets.

@dball
dball / protocol.clj
Last active June 4, 2016 21:14
Protocol Example
(defprotocol UserStore
(load [_ id])
(save! [_ id user])
(delete! [_ id]))
(defrecord Database [db]
UserStore
(load [_ id]
(first (jdbc/query db ["select * from users where id = ?" id])))
...)
(defn charseq-in
[& options]
(let [{:keys [count min-count max-count chars]} options]
(s/coll-of (or chars char?)
:count count
:min-count min-count
:max-count max-count)))
(defn string-in
[& options]
(defn charseq-in
[& options]
(let [{:keys [count min-count max-count chars]} options]
(s/coll-of (or chars char?)
:count count
:min-count min-count
:max-count max-count)))
(defn string-like
[spec-or-k]
(set-env!
:wagons (fn [wagons]
(conj wagons '[sparkfund/aws-maven "5.1.0"
:schemes {"s3" #(org.springframework.build.aws.maven.SimpleStorageServiceWagon.)}]))
:repositories (fn [repos]
(conj repos
'["sparkfund-snapshots" {:url "s3://sparkfund-maven/snapshots"}]))
:dependencies '[[sparkfund/private-secret-library "0.0.1"]])
### Keybase proof
I hereby claim:
* I am dball on github.
* I am dball (https://keybase.io/dball) on keybase.
* I have a public key ASD3cNyASKB_AH3rqwzAKMQBK6ILjglZ9evrD9g90d17kwo
To claim this, I am signing this object:
(defmethod perform :start
[_ config components roles]
(println "Starting persistent service" components)
(let [system (volatile! (system/create-system config components roles))
runtime (Runtime/getRuntime)
shutdown? (promise)]
(.addShutdownHook runtime
(Thread. (fn []
(println "Shutting down persistent service")
(system/stop @system)
1=2-1
1=2-(2-1)
1=2-(2-(2-1))
1=2-(2-(2-(2-1)))
1=2-(2-(2-(2-(2-1))))
1=2-(2-(2-(2-(2-(2-1)))))