[ANN] com.walmartlabs/schematic 1.3.0

108 views
Skip to first unread message

Howard Lewis Ship

unread,
May 22, 2020, 1:26:33 PM5/22/20
to clo...@googlegroups.com
Schematic is a Clojure library which aids in assembling systems from configuration data.

GitHub repo: https://github.com/walmartlabs/schematic

Documentation: https://walmartlabs.github.io/apidocs/schematic/

Featured changes in 1.3.0:

- Uses Component's `transitive-dependencies` function, which handles certain edge cases correctly
- Captures exceptions during component instantiation, with better reporting

--
Howard M. Lewis Ship

Senior Mobile Developer at Walmart Labs

Matching Socks

unread,
May 23, 2020, 8:47:36 AM5/23/20
to Clojure
Sierra's Component README illustrates factory functions that take a complete static configuration at once, followed up by injections.  But, really, it's none of Component's concern how you work a Lifecycle thing into shape for Component to assoc the injections and start it.

In Schematic, sc/create-fn takes a single map as a parameter, but I didn't see the README stating what's in the map.  It seems to me that Schematic would be free to include all static configuration (i.e., everything except other Lifecycle things), or to provide an empty map and assoc the static elements piecemeal along with other Lifecycle things, or anything in between.

The question came to mind because I sometimes wonder where it was intended that Components validate their configuration.  Of course, it hinges on how the wiring-up is done.  If you code it yourself, you can use the factory function (and refrain from assoc), so the factory function can check parameters, which is nice because the resulting Exception does not tie up your Emacs with 100 gigabytes of Component fallout.  On the other hand, if you must code for the general case, you validate stuff only in the start method.

What do you recommend?

Howard Lewis Ship

unread,
May 26, 2020, 1:07:59 PM5/26/20
to clo...@googlegroups.com
 The :sc/create-fn is passed configuration of the component, but not its dependencies, that comes later. This can often be a map->Record function in a namespace.  Or, it can be a custom application that validates the configuration (I use spec) and then calls map->Record.  Component will later assign dependencies and invoke the start method, which is another reasonable place to do validation.
.
Of course, your rec9rd may not implement Lifecycle, you may not even need a record type.  I prefer to avoid records and protocols for my components, wherever possible.  I'm fine with the component being a simple map, and doing some destructuring to get at config and dependencies from simple functions passed the component.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/9522140a-a329-41b8-92ed-5a1eececc6c3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages