Skip to content

Commit

Permalink
patch: Allow passing operations directly to run!
Browse files Browse the repository at this point in the history
  • Loading branch information
julienvincent committed Apr 5, 2024
1 parent bb3c5e2 commit 1534926
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/mallard/src/k16/mallard/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@
(undo! props)
(run-next! props))

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn run
"A run function to be used in a Deps.edn project to execute operations using the file loader.
:init-store! - Should be given a symbol that resolves to a datastore init function.
:load-dir - should be a resource path to a directory containing operation files that will
be loaded using the file loader.
:action - should be given an action to perform. One of #{:up :down :next :undo :redo}"
:load-dir - should be a resource path to a directory containing operation files that will
be loaded using the file loader.
:operations - Should be a symbol resolving to a set of operations
:action - should be given an action to perform. One of #{:up :down :next :undo :redo}"
[{create-ctx-fn :create-ctx!
create-store-fn :create-store!
shutdown-fn :shutdown!
load-dir :load-dir
operations :operations
action :action}]

(let [create-store! (requiring-resolve create-store-fn)
Expand All @@ -52,7 +55,8 @@
(create-ctx))
store (create-store! context)
props {:context context
:operations (loaders.fs/load! load-dir)
:operations (or operations
(loaders.fs/load! load-dir))
:store store}]

(case action
Expand Down
2 changes: 2 additions & 0 deletions packages/mallard/src/k16/mallard/dev.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns k16.mallard.dev
"For use in development, this is a component that can be included in a gx configuration to automatically
run any migrations on system start."
(:refer-clojure :exclude [run!])
(:require
[k16.mallard.api :as api]
[k16.mallard.datastore :as datastore.api]
Expand All @@ -20,6 +21,7 @@
[:or executor/?Operations
[:=> [:cat] executor/?Operations]]]]]])

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(def run!
{:gx/start
{:gx/processor (fn [{:keys [props]}]
Expand Down

0 comments on commit 1534926

Please sign in to comment.