-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add more nixos module features and improve tests
Showing
11 changed files
with
537 additions
and
70 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
services: | ||
datomic-transactor: | ||
image: ${IMAGE} | ||
environment: | ||
DATOMIC_PROTOCOL: sql | ||
DATOMIC_SQL_URL: jdbc:sqlite:/data/datomic-sqlite.db | ||
DATOMIC_SQL_DRIVER_CLASS: org.sqlite.JDBC | ||
DATOMIC_JAVA_OPTS: -Dlogback.configurationFile=/logback.xml | ||
# this one is for the other containers | ||
DATOMIC_HOST: datomic-transactor | ||
# this one is for the host machine | ||
DATOMIC_ALT_HOST: "127.0.0.1" | ||
# shrink ram requirements for test environment | ||
DATOMIC_MEMORY_INDEX_MAX: 32m | ||
DATOMIC_OBJECT_CACHE_MAX: 32m | ||
DATOMIC_MEMORY_INDEX_THRESHOLD: 32m | ||
volumes: | ||
- "/var/lib/datomic-docker/data:/data:z" | ||
- "/var/lib/datomic-docker/config:/config:z" | ||
- "/etc/datomic-docker/logback.xml:/logback.xml:ro" | ||
ports: | ||
- 127.0.0.1:4334:4334 | ||
depends_on: | ||
datomic-storage-migrator: | ||
condition: service_completed_successfully | ||
|
||
datomic-console: | ||
image: ${IMAGE} | ||
command: console | ||
environment: | ||
# you don’t specify the db name in the uri (because console can access all dbs) | ||
DB_URI: "datomic:sql://?jdbc:sqlite:/data/datomic-sqlite.db" | ||
DATOMIC_JAVA_OPTS: -Dlogback.configurationFile=/logback.xml | ||
volumes: | ||
- "/var/lib/datomic-docker/data:/data:z" | ||
- "/etc/datomic-docker/logback.xml:/logback.xml:ro" | ||
ports: | ||
- 127.0.0.1:8081:8080 | ||
depends_on: | ||
datomic-storage-migrator: | ||
condition: service_completed_successfully | ||
|
||
datomic-storage-migrator: | ||
image: ${IMAGE} | ||
volumes: | ||
- "/var/lib/datomic-docker/data:/data:z" | ||
entrypoint: /bin/sh | ||
command: | | ||
-c ' | ||
echo "Creating SQLite database and schema..." | ||
sqlite3 /data/datomic-sqlite.db " | ||
CREATE TABLE IF NOT EXISTS datomic_kvs ( | ||
id TEXT NOT NULL PRIMARY KEY, | ||
rev INTEGER, | ||
map TEXT, | ||
val BLOB | ||
);" | ||
echo "Database initialization complete." | ||
' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
(ns hello | ||
(:require [datomic.api :as d])) | ||
|
||
(def db-uri (let [uri (System/getProperty "datomic.uri")] | ||
(assert uri "datomic.uri property is nil!") | ||
uri)) | ||
|
||
(def schema | ||
[{:db/ident :hello/message | ||
:db/valueType :db.type/string | ||
:db/cardinality :db.cardinality/one | ||
:db/doc "A hello world message"} | ||
|
||
{:db/ident :hello/timestamp | ||
:db/valueType :db.type/instant | ||
:db/cardinality :db.cardinality/one | ||
:db/doc "When the message was created"}]) | ||
|
||
(defn create-database [ts] | ||
(d/create-database db-uri) | ||
(let [conn (d/connect db-uri)] | ||
@(d/transact conn schema) | ||
@(d/transact | ||
conn | ||
[{:hello/message "Hello, Datomic!" | ||
:hello/timestamp ts}]) | ||
conn)) | ||
|
||
(defn -main [] | ||
(println "Creating database and schema...") | ||
(try | ||
(let [ts (java.util.Date.) | ||
conn (create-database ts) | ||
db (d/db conn) | ||
results (d/q '[:find ?m ?t | ||
:where | ||
[?e :hello/message ?m] | ||
[?e :hello/timestamp ?t]] | ||
db)] | ||
(println "Query results:") | ||
(doseq [[message timestamp] results] | ||
(assert (= timestamp ts)) | ||
(println message "at" timestamp)) | ||
(println "Database setup complete!")) | ||
(finally | ||
(d/shutdown true)))) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
data-dir = ./data | ||
host = 127.0.0.1 | ||
memory-index-max = 64m | ||
memory-index-threshold = 16m | ||
object-cache-max = 64m | ||
port = 4334 | ||
protocol = dev | ||
storage-access = remote | ||
storage-admin-password=adminpass | ||
storage-datomic-password=datpass |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
data-dir=./data | ||
host=0.0.0.0 | ||
memory-index-max=256m | ||
memory-index-threshold=32m | ||
object-cache-max=128m | ||
port=4334 | ||
protocol=sql | ||
sql-driver-class=org.sqlite.JDBC | ||
sql-url=jdbc:sqlite:data/db-sqlite.db |
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