Although seemingly unremarkable in appearance, the utility belt is one of Batman's most important tools in fighting crime.
Utility belt has a limited functionality: it only provides commonly used functions wrapping a limited set of dependencies.
Currently it has:
utility-belt.id
- various functions for working with UUIDsutility-belt.base64
- encoding/decoding of base64 into bytes/stringsutility-belt.json
- sets up automatic conversions of Joda time objects to/from JSON, you need to pull inclj-time
andcheshire
if you need to use thoseutility-belt.time
- common functions for date and time calculations, you need to pull inclj-time
if you need to use thoseutilit-belt.conv
- type conversions (string to int, int to string, etc)utlity-belt.component
- small utils which make working with Stuart Sierra's Component a bit easierutility-belt.map-keys
- easy transformations of map keys between kebab and snake caseutility-belt.lifecycle
- helpers to manage Clojure application lifecycle (registering shutdown hooks etc)utility-belt.debug
- helpers for debugging code, mostly locallyutility-belt.validation
- helpers for data validationutility-belt.sanitization
- helpers for data sanitization
Micro wrapper around nREPL server, as easy to use as passing the port number.
⚠️ This is a REPL so take care of securing it!
(def system
{:nrepl-server (utility-belt.component.nrepl/create 23211)})
🙋 Note that the server by default binds to 0.0.0.0
You can pass the address to bind to if you need more control:
(def system
{:nrepl-server (utility-belt.component.nrepl/create 23211"127.0.0.1")})
utility-belt.lifecycle
provides a set of helpers to manage application lifecycle. Best used if you're using Component. The use case is to add graceful shutdown capabilities to long lived applications, and handle things such as stopping the component system during application shutdown.
Example:
(ns app.core
(:require [app.system]
[com.stuartsierra.component :as component]
[utility-belt.lifecycle :as life]))
(def system (atom nil))
(def -main []
(life/register-shutdown-hook :stop-system #(component/stop @system))
(life/register-shutdown-hook :goodbye #(println "BYYYYEEEE 👋"))
(life/install-shutdown-hooks!)
(reset! system (component/start (app.system/create))))
In alphabetical order