Redelay

screenshot of Redelay

Clojure library for first class lifecycle-managed state.

Overview:

This article is a product analysis for the Clojure library "redelay." The library allows for state lifecycle-management in Clojure, inspired by Stuart Sierra's reloaded workflow. The article explains how to create and use State objects, which are similar to delays but resettable and tracked. The library provides an easy way to start and stop the stateful parts of an application, making REPL-driven development faster and more efficient.

Features:

  • Stateful parts management: Easily start and stop stateful parts of an application such as database connections, web servers, schedulers, and caches.
  • REPL-driven development: Restarting stateful parts in the right order makes REPL-driven development easier, faster, and more enjoyable.
  • First-class State objects: Create State objects that are resettable and tracked, similar to Clojure's delays.
  • Small API: The library has a minimal API, requiring only a few functions to create and use State objects.
  • Closeable implementation: State objects implement Java's Closeable interface, allowing for easy closing and restarting of states.
  • Active state tracking: The library keeps track of active states, making it easy to stop them all at once.
  • Easy state reset: Reset a state and start afresh, even if the reference to the state is lost.
  • Error handling: Close active states with bugs or handling issues using the close! function.
  • Value inspection: Inspect the value of a state without starting it using Clojure's peek function.

Summary:

The "redelay" library provides a simple and efficient way to manage the lifecycle of stateful parts in a Clojure application. By using State objects, users can easily start and stop these parts, making REPL-driven development faster and more enjoyable. The library's small API and features such as active state tracking and easy state reset contribute to its usability. Overall, "redelay" is a valuable tool for managing state in Clojure applications.