gemini-2.5-pro| input-price: 1.25 output-price: 10 max-context-length: 200_000 (cost: $0.05) Β· Anfrage: 2025-09-03T11:51:01.408638
Generated by rs-summarizer Version unbekannt
Abstract:
This presentation by Wout Mertens introduces "Mailman," a flexible and highly testable Clojure library designed for building event-driven applications. Born from the need for a maintainable event-handling solution during the development of the Monkeyci CI/CD tool, Mailman provides an abstraction layer over underlying message brokers like JMS and NATS.
The library's architecture is inspired by familiar HTTP frameworks, featuring a central router that dispatches events to specific handlers. It heavily leverages Pedestal's interceptor pattern, allowing developers to manage side effects, validation, and other cross-cutting concerns through a chain of functions that manipulate a shared context map. Key design principles include broker independence, flexibility over rigid frameworks, and a strong emphasis on testability. A standout feature is the ability to easily replace interceptors in tests, enabling the isolation of business logic from slow or unpredictable side effects. The presentation concludes with a live coding session demonstrating these concepts, including how a handler's return value is automatically treated as new events to be published, simplifying complex event-driven workflows.
A Deep Dive into Mailman: A Testable, Event-Driven Clojure Library
:type key.context map. This is the recommended way to handle side effects, add logging, perform validation, or inject dependencies like database connections.replace-interceptors function to test the entire routing and processing logic. This allows developers to swap out interceptors that perform slow or side-effect-heavy operations (e.g., database calls, external API requests) with fast, predictable fakes.destination-mapper function is used to dynamically determine the correct topic or queue for an outgoing event based on its content. Listeners, in turn, specify which destination they subscribe to. The library also handles serialization via codecs, defaulting to EDN.replace-interceptors to test a router. A "slow" interceptor that simulates a network call is replaced with a fake one that returns a fixed value, allowing for a fast and deterministic test of the application logic.