Skip to content

Commit

Permalink
Merge pull request #99 from cognitect-labs/datomic-cloud-support
Browse files Browse the repository at this point in the history
Datomic cloud support
  • Loading branch information
ddeaguiar authored Feb 8, 2019
2 parents 5c19749 + 407d8cd commit e178117
Show file tree
Hide file tree
Showing 15 changed files with 442 additions and 128 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Project related
.rebel_readline_history
my-new-payload.edn
data/
/datomic/
Expand Down Expand Up @@ -48,6 +49,7 @@ Gemfile.lock
.project
*/.settings
.settings
*.iml

# OS X
.DS_Store
Expand Down
12 changes: 12 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{:paths ["src"]
:deps {com.datomic/datomic-free {:mvn/version "0.9.5697"}
com.datomic/client-cloud {:mvn/version "0.8.63"}

io.rkn/conformity {:mvn/version "0.5.1"}

;; Pedestal
io.pedestal/pedestal.service {:mvn/version "0.5.4"}
io.pedestal/pedestal.jetty {:mvn/version "0.5.4"}

com.cognitect/fern {:mvn/version "0.1.5"}}
:aliases {:repl {:extra-paths ["test" "test/resources"]}}}
26 changes: 22 additions & 4 deletions docs/action_literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ the context.

## #vase/query

Run a datalog query and return the results as JSON
Run a datalog query using the [Datomic API](https://docs.datomic.com/on-prem/clojure/index.html)
and return the results as JSON.

| Param | Meaning |
|-------------|------------------------------------------------------------------------------------------------------------------ |
Expand All @@ -83,11 +84,20 @@ If this is the last interceptor in the chain, it generates a response.
If this is not the last interceptor in the chain, it attaches the
query results to the context map at the `:to` key

## #vase.datomic/query

Same as `#vase/query`.

## #vase.datomic.cloud/query

Like `#vase.datomic/query` but runs a datalog query using the [Datomic Cloud Client API](https://docs.datomic.com/client-api/datomic.client.api.html).


## #vase/transact

Execute a Datomic transaction. Return the results (the tx-result) as
JSON. The new database value will be used for any subsequent datalog
queries.
Execute a Datomic transaction [DatomicAPI](https://docs.datomic.com/on-prem/clojure/index.html).
Return the results (the tx-result) as JSON. The new database value
will be used for any subsequent datalog queries.

| Param | Meaning |
|-------------|--------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -102,6 +112,14 @@ If this is the last interceptor in the chain, it generates a response.
If this is not the last interceptor in the chain, it attaches the
transaction result to the context map at the `:to` key.

## #vase.datomic/transact

Same as `#vase/transact`.

## #vase.datomic.cloud/transact

Like `#vase.datomic/transact` but runs a Datomic transaction using the [Datomic Client API](https://docs.datomic.com/client-api/datomic.client.api.html).

## #vase/intercept

Define an interceptor, given code in the descriptor file. The form
Expand Down
8 changes: 8 additions & 0 deletions docs/vase_with_fern.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ sample.
| vase.datomic/transact | Define an interceptor with the Datomic transaction action. |
| vase.datomic/attributes | Define an interceptor that creates Datomic schema from short vector form. |
| vase.datomic/tx | Define an interceptor that executes an arbitrary Datomic transaction. |
| vase.datomic.cloud/connect | Connect to a Datomic Cloud database _and_ act as an interceptor to attach the connection to a request. |
| vase.datomic.cloud/query | Define an interceptor to query a Datomic Cloud database. |
| vase.datomic.cloud/transact | Define an interceptor to transact request bodies as Datomic Cloud entities. |
| vase.datomic.cloud/attributes | Defing an interceptor that creates Datomic Cloud schema from short vector form. |
| vase.datomic.cloud/tx | Define an interceptor that executes an arbitrary Datomic Cloud transaction. |


# `:on-request` and `:on-startup`

Expand Down Expand Up @@ -157,6 +163,8 @@ that the old `#vase/schema-tx` reader literal used. The format is this:
Multiple flags are allowed. Add as many as you like before the
mandatory docstring.

Both `vase.datomic/attributes` and `vase.datomic/tx` have exact matches in `vase.datomic.cloud/attributes` and `vase.datomic.cloud/tx`. The cloud versions work exactly the same way as the On-Prem versions.

# Adding Your Own Literals

One of our goals with the Fern format was to make Vase easier to
Expand Down
39 changes: 26 additions & 13 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,43 @@

;; Datomic
[com.datomic/datomic-free "0.9.5697" :exclusions [[org.slf4j/slf4j-api]
[org.slf4j/slf4j-nop]]]
[org.slf4j/slf4j-nop]
[org.eclipse.jetty/jetty-util]
[org.eclipse.jetty/jetty-client]]]
[com.datomic/client-cloud "0.8.63"]
[io.rkn/conformity "0.5.1" :exclusions [com.datomic/datomic-free]]

;; Pedestal
[io.pedestal/pedestal.service "0.5.4"]
[io.pedestal/pedestal.jetty "0.5.4"]

[com.cognitect/fern "0.1.3"]
;; Pin Jetty versions to avoid conflict between Datomic and Pedestal
[org.eclipse.jetty/jetty-util "9.4.10.v20180503"]
[org.eclipse.jetty/jetty-client "9.4.10.v20180503"]

;; Nice errors
[expound "0.3.1"]
;; Configuration
[com.cognitect/fern "0.1.5"]

;; Replace Java EE module for JDK 11
[javax.xml.bind/jaxb-api "2.3.0"]

;; Cleanup
[commons-codec "1.11"]
[cheshire "5.8.0"]]
:main com.cognitect.vase.main
:pedantic? :warn
:uberjar-name "vase-standalone.jar"
:plugins [[camechis/deploy-uberjar "0.3.0"]]
:jvm-opts ~(let [version (System/getProperty "java.version")
[major _ _] (clojure.string/split version #"\.")]
(if (>= (java.lang.Integer/parseInt major) 9)
["--add-modules" "java.xml.bind"]
[]))

:main ^:skip-aot com.cognitect.vase.main
:pedantic? :warn
:uberjar-name "vase-standalone.jar"
:plugins []
:jvm-opts ~(let [version (System/getProperty "java.version")
[major _ _] (clojure.string/split version #"\.")]
(if (<= 9 (java.lang.Integer/parseInt major) 10)
["--add-modules" "java.xml.bind"]
[]))
:test-selectors {:default (complement :integration)
:cloud :integration
:all (constantly true)}

:profiles {:srepl {:jvm-opts ^:replace ["-XX:+UseG1GC"
"-Dclojure.server.repl={:port 5555 :accept clojure.core.server/repl}"]}
:dev {:aliases {"crepl" ["trampoline" "run" "-m" "clojure.main/main"]
Expand Down
7 changes: 7 additions & 0 deletions samples/petstore/deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{:deps {com.cognitect/pedestal.vase {:local/root "../../"}
io.pedestal/pedestal.service {:mvn/version "0.5.4"}
io.pedestal/pedestal.jetty {:mvn/version "0.5.4"}
ch.qos.logback/logback-classic {:mvn/version "1.2.3"}
org.slf4j/jul-to-slf4j {:mvn/version "1.7.25"}
org.slf4j/jcl-over-slf4j {:mvn/version "1.7.25"}
org.slf4j/log4j-over-slf4j {:mvn/version "1.7.25"}}}
10 changes: 5 additions & 5 deletions samples/petstore/project.clj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
(defproject pet-store "0.9.3-SNAPSHOT"
(defproject pet-store "0.9.4-SNAPSHOT"
:description "Vase sample application: Pet Store demo, partial"
:url "https://github.com/cognitect-labs/vase/tree/master/samples/pet-store"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.9.0"]
[io.pedestal/pedestal.service "0.5.3"]
[io.pedestal/pedestal.jetty "0.5.3"]
[io.pedestal/pedestal.service "0.5.4"]
[io.pedestal/pedestal.jetty "0.5.4"]
[ch.qos.logback/logback-classic "1.2.3" :exclusions [org.slf4j/slf4j-api]]
[org.slf4j/jul-to-slf4j "1.7.25"]
[org.slf4j/jcl-over-slf4j "1.7.25"]
[org.slf4j/log4j-over-slf4j "1.7.25"]
[com.cognitect/pedestal.vase "0.9.3-SNAPSHOT"]]
[com.cognitect/pedestal.vase "0.9.4-SNAPSHOT"]]
:min-lein-version "2.0.0"
:resource-paths ["resources"]
:profiles {:dev {:aliases {"run" ["trampoline" "run" "-m" "com.cognitect.vase.main" "petstore.fern"]}
:dependencies [[io.pedestal/pedestal.service-tools "0.5.3"]]}})
:dependencies [[io.pedestal/pedestal.service-tools "0.5.4"]]}})
Loading

0 comments on commit e178117

Please sign in to comment.