This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-07
Channels
- # announcements (11)
- # babashka (29)
- # beginners (70)
- # biff (13)
- # calva (1)
- # clojure (24)
- # clojure-europe (125)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-portugal (2)
- # clojure-uk (3)
- # clojurescript (9)
- # core-async (29)
- # cursive (4)
- # emacs (10)
- # etaoin (14)
- # events (3)
- # fulcro (10)
- # funcool (4)
- # helix (1)
- # honeysql (12)
- # introduce-yourself (1)
- # jobs (2)
- # juxt (2)
- # lsp (1)
- # off-topic (17)
- # polylith (58)
- # portal (20)
- # remote-jobs (2)
- # shadow-cljs (2)
- # squint (4)
- # tools-deps (9)
Hi guys! I'm trying to integrate biff as a base into a polylith project. Did anyone try to do this?
Namely, I would like to decouple the xtdb node from starting the entire biff system. How can I pass an existing node on startup?
Hi! I haven't used polylith at all myself. But to pass in a node yourself, you'll need to remove the biff/use-xt
component and then include a :biff.xtdb/node
key in the map that you pass to biff/start-system
. You'll also probably want to include a stop fn for the node (in the :biff/stop
key) so that biff/refresh
works.
(defn start-xtdb-node []
...)
(def components
[biff/use-config
biff/use-random-default-secrets
;biff/use-xt
biff/use-queues
biff/use-tx-listener
biff/use-outer-default-middleware
biff/use-jetty
biff/use-chime
(biff/use-when
:com.example/enable-beholder
biff/use-beholder)])
(defn start []
(let [node (start-xtdb-node)]
(biff/start-system
{:biff.xtdb/node node
:biff/stop (list #(.close node))
...}))
...)
Thanks, I will try it out!
I also need to decouple the config files location, is there a similar way to do that?
Yep, there's a :biff/config "config.edn"
line in that map which you can change. If you want to use a different config format altogether, you can remove the biff/use-config
component and replace it with your own code.
I will let you know as soon as I can try
Thank you!
You're welcome!
@U7YNGKDHA It's kind of working with a custom config and my own node, but I get this error when trying to log into the example app:
[qtp424628542-31] INFO com.biffweb.impl.middleware - 31ms 303 post /auth/send
[qtp424628542-37] INFO com.biffweb.impl.middleware - 2ms 200 get /auth/printed/
[qtp424628542-36] ERROR com.biffweb.impl.middleware - Exception while handling request
clojure.lang.ExceptionInfo: Transaction violated a constraint {:tx ([:xtdb.api/match #uuid "4ce0c68d-6523-4737-bca8-56ed29752cf3" nil] [:xtdb.api/put {:user/joined-at #inst "2022-11-07T21:44:07.494-00:00", :user/email "", :xt/id #uuid "4ce0c68d-6523-4737-bca8-56ed29752cf3"}] [:xtdb.api/fn :biff/ensure-unique {:user/email ""}])}
Oh, I forgot that the use-xt component also adds a transaction function to database on startup, which is used for uniqueness constraints. not at my computer atm, but you can look at the source of biff/use-xt and copy over the tx fn part.
basically call this function: https://github.com/jacobobryant/biff/blob/master/src/com/biffweb.clj#L470 with biff/tx-fns as the parameter
Necropost Alert! @U01V67SBM55 did you end up integrating Biff into Polylith in some fashion?