Fork me on GitHub
#duct
<
2019-08-03
>
Ahmed Hassan18:08:11

When I change .sql files in Hugsql in duct and run (reset), changes are not projected in the project.

Ahmed Hassan18:08:55

Are sql files when changed reloaded to system, by using (reset)?

weavejester18:08:00

Not automatically. Duct has no inherent connection to Hugsql, so they’d have to be refreshed by whatever Hugsql component you’re using.

👍 4
weavejester18:08:16

Or in your dev script.

👍 4
Ahmed Hassan19:08:03

(hugsql/def-db-fns "myapp/db/sql/my_sql_statements.sql") this is function included in boundary namespace in which duct.database.sql.Boundary is implemented.

Ahmed Hassan19:08:19

should I wrap hugsql/def-db-fns in ig/init-key multi-method and pass "myapp/db/sql/my_sql_statements.sql" to it inside config.edn?

weavejester19:08:40

If you only care about refreshing the DB functions during development, you should probably write a development function for that, and hook it into a custom resetfunction.

Ahmed Hassan19:08:24

Like a function to reload namespaces in which (hugsql/def-db-fns "myapp/db/sql/my_sql_statements.sql") sort of statements are defined? But how would such a function know which .sql files have changed.

weavejester19:08:15

You’d probably want to check the timestamps of the files and compare them to the timestamps you checked last time.

👍 4
Ahmed Hassan19:08:28

Brilliant, so I'll also have to keep track of .clj namespaces in which "myapp/db/sql/my_sql_statements.sql" is referred?

weavejester19:08:34

Yes. You might want to add metadata to the namespaces. There might even be a project out there that does this already. You’ll need to research and experiment 🙂

👍 4
Ahmed Hassan19:08:11

Thanks for directions, that would make workflow reloaded++ 🙂

Ahmed Hassan19:08:08

I can watch .sql files with https://github.com/juxt/dirwatch. And dispatch some function on file change.

Ahmed Hassan19:08:39

What would that function be like, which would notify duct/integrant that respective namespace to the changed .sql file need to be reloaded?

weavejester19:08:07

Ideally you wouldn’t complect the ideas of file watching and reloading. You’d write a function that would reload the SQL files if any were changed since last it was run.

👍 4
rboyd23:08:51

is there syntax for duct.module/ataraxy handlers to do async? I see https://github.com/weavejester/ataraxy/blob/ac4e441afaf8fa89dcbe93f319659832f7bd9c48/src/ataraxy/handler.clj#L21 but I'm confused how I would declare my async handler in my config

weavejester23:08:03

You return handlers that take three arguments instead of one, and set the :async? argument on the Jetty adapter to true.