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 app.config) | |
(def local-dev-config | |
{:enable-schedule false | |
:db { | |
:username "local-user" | |
:password "password" | |
}}) | |
(def test-config |
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
(def base-config | |
{ | |
:value "some value" | |
}) | |
(defn- merge-cfg-item | |
[base-item override-item] | |
(cond | |
(and (every? map? [base-item override-item]) (not (contains? override-item :replace-all!))) | |
(merge-with merge-cfg-item base-item override-item) |
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 | |
^:cfj-config | |
example.config | |
(:require [confijulate.core :as cfj])) | |
(def ^:cfj-base base-config | |
{:db | |
{:classname "net.sf.log4jdbc.DriverSpy" | |
:subprotocol "log4jdbc" | |
:subname "postgresql:example" |
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 | |
^:cfj-config | |
my-app.config | |
(:require [confijulate.core :as cfj])) | |
(def ^:cfj-base base-config | |
{ | |
:jobs | |
{:enable-schedule false} ;;disabled by default | |
} |
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 leader-guarantee.core | |
(:import (org.jgroups.blocks.locking LockService) | |
(org.jgroups.protocols CENTRAL_LOCK) | |
(org.jgroups JChannel) | |
(java.util.concurrent.locks Lock))) | |
(defn- get-lock | |
[lock-service with-lock-fn] | |
(fn [] | |
(let [lock (.getLock lock-service "leader")] |
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 leader-guarantee.core | |
(:import (org.jgroups.blocks.locking LockService) | |
(org.jgroups.protocols CENTRAL_LOCK) | |
(org.jgroups JChannel) | |
(java.util.concurrent.locks Lock))) | |
(def get-lock-threads (atom {})) | |
(defn- get-lock | |
[lock-service lock-promise] |
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 my-app.scheduler | |
(:use leader-guarantee.core | |
confijulate.core) | |
(:require [clojurewerkz.quartzite.scheduler :as qs])) | |
(defn initialise | |
"The initialisation function for the scheduling system" | |
[] | |
(when (get-cfg :jobs :enable-schedule) ;; Still may want to disable schedule in local dev environment | |
(when-leader "my-app-cluster" |
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
(defn fizzbuzz | |
[n] | |
(let [r [(= 0 (mod n 3)) (= 0 (mod n 5))]] | |
(get {[true false] "fizz" [false true] "buzz" [true true] "fizzbuzz"} r n))) | |
(map fizzbuzz (range 1 100)) |
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
(use 'korma.core) | |
(use 'korma.db | |
(defdb db | |
(postgres {:naming {:keys (comp keyword clojure.string/upper-case name)}})) | |
(declare user) | |
(defentity address | |
(transform identity) |
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
0 |