At Start
The server can be configured from the command-line when it is started. For example, the following will start a server with the dev
alias and default configuration:
clj -M:dev -m dev
By default, it will use the configuration found at config.edn
:
{:backends
[{:allow-create true
:cfg
{:db-name "jobtech-taxonomy-db" ,
:server-type :datomic-local,
:storage-dir ".taxonomy-db",
:system "jobtech-taxonomy"},
:id :datomic-v.dev,
:init-db {:filename "resources/taxonomy.zip", :unzip true},
:type :datomic}],
:jobtech-taxonomy-api
{:auth-tokens {:111 :user, :222 :admin}, :user-ids {:222 "admin-1"}},
:mappings {:source-directory "resources/mappings"},
:options
{:deployment-name "Default Develop", :jetty-threads 32, :log-level :debug, :port 8080}}
The server port depends on which alias is being used.
The configuration file can be explicitly set using the --config
flag or its short form -c
:
clj -M:dev -m dev --config config.edn
The server port can be explicitly set using the --port
flag or its short form -p
:
clj -M:dev -m dev --port 5020
Summary of command-line flags
The following table is a summary of the available flags.
Flag | Argument | Description |
---|---|---|
--config , -c | Configuration file | Specify which configuration file to use. |
--port , -p | Port number | Specify the server port at which the API can be reached. |
Provided configurations
Here is a list of some configuration files provided in this repository. For the actual configuration files used when the API is deployed, see the config*.edn
files in the repository jobtech-taxonomy-api-infra
.
Path | Description |
---|---|
config.edn | Configuration with sane defaults suitable for development. |
env/dev/resources/config.dev.edn | Default configuration used with the dev alias. |
env/prod/resources/config.edn | Default configuration used for production. |
config.container.edn | Configuration suitable for containers. |
test/resources/config/config.edn | Configuration used in some tests. |
test/resources/config/config.datomic.edn | Configuration used for testing Datomic. |
test/resources/config/config.datahike.edn | Configuration used for testing Datahike. |
test/resources/config/config-local-storage.edn | Configuration used for testing local storage. |
Configuration file structure
The configuration file contains an EDN-encoded data structure with the following keys:
Key | Required? | Description |
---|---|---|
:backends | Yes | A vector of configurations for database backends. Each configuration has an id. |
:database-backend | Key referring to the id of a backend under :backends . | |
:compare-backends | List backends to compare. | |
:options | Options for the server, such as port number. | |
:jobtech-taxonomy-api | Settings regarding the taxonomy. |
At the :backends
key, a set of configurations for database backends is listed, each with a unique id at its :id
key. Under normal conditions, there will only be one backend configuration which is used. In that case, there is no need to provide values for the keys :database-backend
and :compare-backends
.
However, for the sake of comparing the correctness of different database backends, it is possible to list many backends at the :backends
key. If the :database-backend
key does not have a value, by default the first backend in the list of backends will be used. the :compare-backends
can be set to a vector of backend ids for backends to be compared. It is also possible to specify which one of the backends that should be used by the API at the :database-backend
key.
Here is an example of what a configuration can look like:
{:id :prod
:options {:port 3000
:log-level :info}
:wanderung-source :nippy
:wanderung {:nippy {:wanderung/type :nippy :filename "./test/data/taxonomy.nippy"}}
:database-backend :datahike
:compare-backends [:datomic :datahike]
:backends [{:id :datahike
:type :datahike
:threads 12
:cfg {:store {:backend :mem}
:attribute-refs? true
:name "from-nippy"}}
{:id :datomic
:type :datomic
:threads 12
:cfg {:db-name "jobtech-taxonomy-prod-2023-02-07-11-19-36"
:server-type :ion
:region "eu-central-1"
:system "tax-prod-v4"
:endpoint "http://entry.tax-prod-v4.eu-central-1.datomic.net:8182/"}}]}
Under the :backends
key, we see the backends with ids :datahike
and :datomic
. Of these two, we specify that :datahike
should be used at the :database-backend
key and that the results of the two backends should be compared at the :compare-backends
key.