Skip to content

Data-driven system definition #41

@weavejester

Description

@weavejester

Currently the system is created through the component/system-map function:

(defn new-system [config]
  (let [config (meta-merge base-config config)]
    (-> (component/system-map
         :app     (handler-component (:app config))
         :http    (jetty-server (:http config))
         :example (endpoint-component example-endpoint))
        (component/system-using
         {:http [:app]
          :app  [:example]}))))

But instead we could define the system via a data structure:

{:components
 {:app  duct.component.handler/handler-component
  :http ring.component.jetty/jetty-server}
 :endpoints
 {:example bar.endpoint.example/example-endpoint}
 :dependencies
 {:http [:app]
  :app  [:example]}}

And then have a system-factory function to construct the new-system function from the data structure.

(def new-system
  (system-factory (read-edn "foo/system.edn")))

As well as reducing the amount of code, it would also allow generators to more easily add components and endpoints to the system.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions