Optional: Integrant methods for a host that uses it (SPEC §10). The only
namespace of the base that requires integrant; nothing else depends on it,
and a host without Integrant calls dev.arkaitz.web-base/handler and
start itself.
A config for ::handler holds functions — routes, the subject function,
layouts — which EDN cannot express, so a host writes it as an Integrant
component of its own and refers to it, or builds the map in code:
{::wb/handler {:routes #ig/ref :my/routes :session {...} ...}
::wb/server {:handler #ig/ref ::wb/handler :port 3000}}
config/readers is merged in so #wb/env works in the same EDN, and the
two-argument form takes readers of the host's own.
Optional: Integrant methods for a host that uses it (SPEC §10). The only
namespace of the base that requires integrant; nothing else depends on it,
and a host without Integrant calls `dev.arkaitz.web-base/handler` and
`start` itself.
A config for `::handler` holds functions — routes, the subject function,
layouts — which EDN cannot express, so a host writes it as an Integrant
component of its own and refers to it, or builds the map in code:
{::wb/handler {:routes #ig/ref :my/routes :session {...} ...}
::wb/server {:handler #ig/ref ::wb/handler :port 3000}}
`config/readers` is merged in so `#wb/env` works in the same EDN, and the
two-argument form takes readers of the host's own.(init config)(init config ks)ig/init for a host's system, ks as Integrant takes them. When a key throws, what
had started is halted — ig/init leaves a partial system behind and nobody else holds
it — and the failure is rethrown as an ex-info whose data is :key, the Integrant
key that threw, and :config-key, when that key's own exception names one — a
web-base or db-base refusal does — and nothing else.
The message is the failing key's own exception, just under Integrant's wrapper: never
Integrant's data, which carries the whole resolved configuration of that key (:value,
:system), and not the innermost cause either, which is a driver's and says whatever
the driver says. Of the key's own data only :config-key is copied: the rest may be
what it refused, a password included.
`ig/init` for a host's system, `ks` as Integrant takes them. When a key throws, what had started is halted — `ig/init` leaves a partial system behind and nobody else holds it — and the failure is rethrown as an `ex-info` whose data is `:key`, the Integrant key that threw, and `:config-key`, when that key's own exception names one — a web-base or db-base refusal does — and nothing else. The message is the failing key's own exception, just under Integrant's wrapper: never Integrant's data, which carries the whole resolved configuration of that key (`:value`, `:system`), and not the innermost cause either, which is a driver's and says whatever the driver says. Of the key's own data only `:config-key` is copied: the rest may be what it refused, a password included.
(read-string s)(read-string readers s)Integrant's reader with the base's tags added, or with the readers given —
config/env-file-readers for a development machine, say.
Integrant's reader with the base's tags added, or with the readers given — `config/env-file-readers` for a development machine, say.
(run! {:keys [banner] :as options} args)The whole of a host's -main: reads config (a classpath resource), with the readers
of env-file when named, puts a port given as the first of args at port-path,
starts the system, prints (banner system), halts it on shutdown, and blocks the
calling thread — the server's threads do not keep a JVM alive on their own.
(defn -main [& args] (wbi/run! {:config "config.edn" :env-file "env.local.edn" :port-path [::wb/server :port] :banner #(str "serving on " (get-in % [::wb/server :port]))} args))
A bad port, a missing or malformed resource, a variable nobody set, a system that
fails to start or a banner that throws prints one line to *err* — the failure's
message, never the configuration — and exits with status 1, whatever had started
halted first.
The whole of a host's `-main`: reads `config` (a classpath resource), with the readers
of `env-file` when named, puts a port given as the first of `args` at `port-path`,
starts the system, prints `(banner system)`, halts it on shutdown, and blocks the
calling thread — the server's threads do not keep a JVM alive on their own.
(defn -main [& args]
(wbi/run! {:config "config.edn"
:env-file "env.local.edn"
:port-path [::wb/server :port]
:banner #(str "serving on " (get-in % [::wb/server :port]))}
args))
A bad port, a missing or malformed resource, a variable nobody set, a system that
fails to start or a banner that throws prints one line to `*err*` — the failure's
message, never the configuration — and exits with status 1, whatever had started
halted first.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |