This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-08
Channels
- # announcements (1)
- # babashka (39)
- # beginners (44)
- # clj-kondo (10)
- # cljdoc (24)
- # clojure (49)
- # clojure-austin (2)
- # clojure-berlin (6)
- # clojure-europe (13)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-uk (1)
- # core-async (11)
- # cursive (7)
- # datahike (3)
- # datalevin (2)
- # fulcro (1)
- # hyperfiddle (40)
- # jobs (12)
- # juxt (5)
- # lsp (9)
- # nyc (1)
- # off-topic (27)
- # re-frame (7)
- # releases (3)
- # shadow-cljs (9)
- # timbre (6)
- # xtdb (2)
- # yamlscript (1)
Hello. Anybody could help me creating a driver for Metabase?
As far as I understand, Metabase Client is about calling HTTP endpoints with JSON: https://www.metabase.com/learn/administration/metabase-api
You can checkout a Telegram client and borrow the approach: https://github.com/igrishaev/teleward/blob/master/src/teleward/telegram.clj
The message is deleted so I cannot help. But I work at Metabase and could probably answer your question if I knew what it was
Hi everyone! I've got a library/framework question. I've been super intrigued with this common lisp library, and have been trying to hunt down a Clojure equivalent if it exists: https://github.com/rabbibotton/clog. The basic idea is that a backend server running common lisp serves up a web page. Instead of writing event handlers and javascript on the frontend to handle interactivity and DOM changes, events are streamed back to the backend server over a websocket connection. The code that handles those events is processed on the backend server, and any HTML or content changes are streamed back to the website in response. Does anybody know of a Clojure-based "streaming HTML" library like this?
I haven't used htmx or this clojure library wrapping it https://github.com/whamtet/ctmx but I think that's in the same vein. Also it's not exactly what you're describing and may not be ideal for that use case, but https://github.com/hyperfiddle/electric is an interesting take on backend/frontend app development that might be worth checking out if you haven't heard of it (@UEENNMX0T beat me to this 🙂)
Electric looks like what I'm after! The thing that really interested me about CLOG is the potential to make a reactive app and to keep all of the functionality on the server, I will check it out 👍 And what a fantastic git repo and set documentation and examples. Well done Hyperfiddle
ther's also https://github.com/tatut/ripley
One thing about electric is that once you have a the project setup, it's my favorite backend+frontend development experience. But I think it's worth mentioning that what's nice about "totally backend driven frontend" like the Clog thing you posted (at least this is my impression, I haven't used it) is that it spares you from having to think about the frontend/js it at all, you're completely in "backend land". With electric you ARE making your project into a clj+cljs project and you are responsible for the cljs compilation of your app, and the web serving. You do get full client control in cljs which can be nice or necessary, and very seamless client/server integration. But still a clj+cljs app is IMO a ton more complex to develop and use than a pure clj, due to the compilation step, multiple contexts, etc. Just seems worth mentioning because Clog seems like the goal is "I don't want to have to think about the client I just want to get a webpage" while electric currently is more about how to best build a full stack clj+cljs app once you're committed to doing so.
My Ripley is HTML live updates via websockets. It doesn’t have a ui widget library as such.
After looking at the docs and examples, you're right in your assessment @U064UGEUQ. Seems like the complexity is a little reduced compared to setting up two separate CLJ + CLJS projects, just being able to work in one environment or one file for everything is a huge win in my book. Maybe I'll write my own CLOG for Clojure if it gets to be too much still 😛
Ripley (as well as other “everything on the server” do have tradeoffs as you need a constant connection, but you can get radically simpler apps for many cases. I for one dislike working with the js ecosystem, so a single Clojure app is my preference.
(shameless plug) here’s some examples of Ripley apps: https://github.com/tatut/xtdb-inspector and https://github.com/tatut/REPLey (also check out the examples folder in the ripley repo)
Very cool demos @U11SJ6Q0K, I'll clone some of them and check them out. Good to know the library author is on slack for possible debugging help too 😉
Does anyone know of a clojure function or lib that helps with reading a file that continuously is written to? In this case, it is a log file with one log entry per line. I want to monitor the log files and parse new entries.
Don't know of any Clojure libs but I'd use whatever Java can give me. Just in case, the query for online search is "tail -f"
(note the double quotes).
With hawk I'd still have to manage how far I have read the files so far, right?
> Don't know of any Clojure libs but I'd use whatever Java can give me. Just in case, the query for online search is "tail -f" (note the double quotes). Interesting. I might just be able to use that with the new clojure process api.
Oh, I didn't mean to use the tail
exe directly. :) I meant that people would most often search for something like "tail -f" in java
and there should be some answers on how to do it with some Java library or maybe even built-in JDK stuff.
> Oh, I didn't mean to use the tail exe directly. 🙂 Gotcha! Yeah, I already found the Watcher API added in Java 7. I just hoped there might be something that works on a per-file basis not just directory. But the comments so far are already helpful
In case you are interested, this works pretty well so far.
(defn create-file-reader
[^File log-file]
(let [process (process/start "tail" "-F" (.getAbsolutePath log-file))]
(async/go
(let [scanner (Scanner. ^InputStream (:out process))]
(while (.hasNextLine scanner)
(println (.nextLine scanner)))))
process))
Also already played around with putting the read lines onto a channel which is also super easyYou shouldn't use go
here since .hasNextLine
is blocking. I'd use a plain future
or, if you need core.async
, thread
inside that go
.
Sorry, I don't understand. Is it not okay to wait for blocking functions in go? My core.async knowledge is .... lacking. 😅
Ah okay. So indefinitely blocking a go
block is bad.
So this is better
(async/thread
(let [scanner (Scanner. ^InputStream (:out process))]
(while (.hasNextLine scanner)
(handler-fn (.nextLine scanner)))))
Sorry, switched the plain println
to a handler-function that does something with the read line.
or just (future ....)
some java code examples: https://stackoverflow.com/questions/557844/java-io-implementation-of-unix-linux-tail-f
Is Pedestal still the go-to for HTTP Server or is there anything else that should be considered?
Pedestal is much more than a server. Depends on what you need. If you need many things that Pedestal offers and you already know Pedestal, I wouldn't look at anything else. If you need something simple then perhaps plain Ring with e.g. Jetty will suffice.
In that case, I'd go with something minimal. Any web server will do, it doesn't sound like you need the absolute maximum of throughput or some advanced features. Http-kit is also a fine choice, IIRC it's easier to set up than other servers since it's native to Clojure. With 2-3 endpoints I wouldn't even use a routing library.
my little one off stuff tends to look like https://downey.family/p/2023-08-08/whynter.cljc.html which uses undertow as the webserver, and relies on its built in routing stuff, and does some tricks to bundle a deps file, clojure source and clojurescript source all in one file
http-kit is one of the better ones but it lacks some tooling for introspection that might be desirable depending on your usecase. I think @U04V70XH6 has recommended just using the ring netty adapter in the past because netty has really good tooling for introspection from the java world?
That would mostly be relevant in high-volume cases though, if it's just for a hobby project or something just go with what's easy to grok for you.
http-kit is not great from an observability standpoint because it's "non-standard". At work, we use https://github.com/sunng87/ring-jetty9-adapter which is actually Jetty 11 under the hood (despite the name). Using standard Ring and its Jetty 9 adapter is fine for a small p.o.c. project but Jetty 9 is EOL in terms of any support and Ring's adapter isn't likely to get updated so the sunng adapter is the way to go as far as I'm concerned.
(we used http-kit for a while in production -- it's great, but New Relic doesn't support it so you don't get good metrics coverage on it)
https://github.com/eclipse/jetty.project/issues/7958 clarifies that Jetty 9 still receives security fixes and will continue to receive them until after the last paying Webtide customer has migrated off Jetty 9. (Date unknown.) So the solution is pretty simple actully. What we need is for a benefactor (such as Bill Gates) to subscribe to Webtide, in perpetuity.
But in answer to OP's question, I like Pedestal. Pedestal is pleasant for small projects (like its own tutorial) and presumably works for bigger things too. There is something to be said for using the same hammer for all nails, and Pedestal is very flexible in that sense. Also, I like having it underpinned by something that speaks the CVE lingo, like Jetty.
My two cents, you can get pedestal up and running in a dozen lines of code and it's something you can easily grow into. I'd start there (http://www.pedestal.io has good getting started docs).