clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
timsgardner 2020-10-31T01:14:23.428100Z

that's interesting, what's wrong with pulling in spec @borkdude?

Adrian 2020-10-31T15:02:39.440700Z

Hi all! I have two stupid questions πŸ™‚

Adrian 2020-10-31T15:03:36.441800Z

I am playing around with luminus and defined the password column in the users table as TEXT

Adrian 2020-10-31T15:04:13.442100Z

how do I read the value as string

Adrian 2020-10-31T15:04:28.442500Z

(I am using H2 database)

Adrian 2020-10-31T15:06:50.443600Z

because the library retrieves something like this: :pass #object[org.h2.jdbc.JdbcClob 0x3aa10bc8 "clob2: 'bcrypt+sha512$914ff82438d740391603a9771bf05108$12$d06f3f7a38812e86accd15a690d3b4c5b05a34c0b8549431'"

jumar 2020-11-03T07:50:34.066300Z

Something very similar is here: https://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples#SELECT

Schmoho 2020-10-31T15:13:58.443800Z

Not really that familiar with Luminus, but which library? clojure.java.jdbc?

Adrian 2020-10-31T15:58:07.444500Z

Thanks! It works. πŸ™‚

Adrian 2020-10-31T16:13:53.446500Z

The second stupid question would have been: how do drop and re-create the table with VARCHAR type by migrations? I didn't used it ever.

Alex Bishop 2020-10-31T18:22:03.447100Z

The following worked for me in Postgres - note that h2 seems to use slightly different syntax*

;; REPL
(in-ns 'user)
(create-migration "change-author-type")

;; <timestamp>-change-author-type.up.sql
ALTER TABLE posts
      ALTER COLUMN author TYPE VARCHAR (300)

;; <timestamp>-change-author-type.down.sql
ALTER TABLE posts
      ALTER COLUMN author TYPE TEXT

;; REPL
(migrate) ; changes to VARCHAR
(rollback) ; rollsback to TEXT
*h2 syntax (untested):`ALTER TABLE tableName ALTER COLUMN columnName SET DATA TYPE dataType` Btw, I can recommend https://pragprog.com/titles/dswdcloj3/web-development-with-clojure-third-edition/ for a detailed dive into. Luminus.

Adrian 2020-10-31T19:24:09.447500Z

Thank you very much!

Test This 2020-10-31T19:44:01.451200Z

Can someone please recommend or comment on choice between aleph and http-kit. I have been trying to avoid asking that question. I have looked at both and both seem nice to use. But I want to know from the perspective of (1) bugs encountered; a few days ago someone mentioned about experiencing deadlocks with aleph. (2) which one is expected to be around for longer. (3) limitations such as being able to use other libraries with it, available middleware etc. (4) performance in production. Thank you.

seancorfield 2020-10-31T20:00:55.451700Z

@curiouslearn Any reason to prefer either of those over Jetty?

seancorfield 2020-10-31T20:02:28.453300Z

We've run both Jetty and http-kit in production. We started with Jetty but saw occasional, unexplained "thread death" exceptions, so we switched to http-kit and it was fine, but support by monitoring software (New Relic) wasn't great so we switched back to Jetty (a more recent version), and it's been rock-solid in production for years.

seancorfield 2020-10-31T20:04:57.455Z

aleph and http-kit are both special custom things and neither are as widely-used or as well maintained and well supported as Jetty. Last I saw, aleph was not being maintained and Zach was looking for someone to take it over. http-kit is in a similar situation, but slightly better maintained.

mpenet 2020-10-31T20:07:08.456400Z

Jetty is very stable

mpenet 2020-10-31T20:07:31.457200Z

I d say it's the safe choice right now

Test This 2020-10-31T20:07:34.457400Z

I want something that is easy to use with websockets. Also, while I don't understand this well, I think something that is async would be better in terms of the server's capability in terms of number of concurrent connections it can handle on a very basic server, say a $20 per month Digital Ocean instance.

seancorfield 2020-10-31T20:08:05.458500Z

You'd probably be surprised at just how performant Jetty is.

mpenet 2020-10-31T20:08:16.459200Z

WS is somewhat a hack with most jetty adapters for clojure

mpenet 2020-10-31T20:08:40.460700Z

Yeah I had jetty take crazy loads

Test This 2020-10-31T20:08:51.461200Z

Thank you. Any pointers on which libraries to use for websocket connections with Jetty? Thank you.

seancorfield 2020-10-31T20:09:37.463200Z

We're using netty directly for a WS-based app but that means a fair bit of Java interop (and heavy use of core.async). I wouldn't recommend that approach until you've got some serious production Clojure experience under your belt.

hanDerPeder 2020-11-01T18:19:16.003100Z

Sorry to jump in, but why not?

seancorfield 2020-11-01T19:25:11.003500Z

@peder.refsnes core.async is pretty hard to use and complex on its own -- I see non-beginner Clojurians running into all sorts of issues when they're learning core.async πŸ™‚ -- and netty with interop is also non-trivial on its own. So then you're combining two non-trivial things with asynchronous behavior. It's a lot of stuff to learn and get working, if you're also still struggling with a bunch of Clojure basics.

hanDerPeder 2020-11-01T20:00:35.003700Z

aha, I see thanks. can confirm the β€˜all sorts of issues with core.async’ part πŸ™‚

mpenet 2020-10-31T20:10:00.464200Z

For ws not sure, we used erlang for that

mpenet 2020-10-31T20:10:52.466Z

Netty is quite complex, it's easy to make mistakes if you don't know it well

Test This 2020-10-31T20:10:58.466200Z

Yes, I would like to avoid that (using netty directly or erlang). But I need websockets for sure.

Test This 2020-10-31T20:11:03.466600Z

What is the option then?

mpenet 2020-10-31T20:11:24.467400Z

Vertx is a decent solution probably

Test This 2020-10-31T20:11:25.467500Z

That is mainly the reason I was drawn to aleph and http-kit.

mpenet 2020-10-31T20:11:45.468500Z

It's essentially a thin wrapper over netty

Test This 2020-10-31T20:12:14.469400Z

@mpenet would you recommend VertX over http-kit and aleph. Thank you.

borkdude 2020-10-31T20:12:21.469600Z

Both the client and server from http-kit are also available in babashka.

mpenet 2020-10-31T20:12:41.470200Z

Just for ws yes

mpenet 2020-10-31T20:12:59.471Z

Otherwise give a try to jetty

seancorfield 2020-10-31T20:13:29.472Z

@curiouslearn What is your web socket client? JS and http://Socket.IO, or some custom ClojureScript thing?

Test This 2020-10-31T20:13:48.472400Z

Standard JS. I am using Svelte on client side.

borkdude 2020-10-31T20:14:13.472800Z

Btw, we're using yada + aleph at work and it's been very stable for us

borkdude 2020-10-31T20:14:21.473Z

We're using websockets as well

Test This 2020-10-31T20:14:51.473400Z

Thank you @borkdude. Did you experience any deadlocks with aleph?

Test This 2020-10-31T20:15:13.474Z

Or other bugs

borkdude 2020-10-31T20:16:14.475500Z

I can't say that I have. There is a common issue that when you don't consume an inputstream on error, this can cause resource problems, but I believe this is documented somewhere

Test This 2020-10-31T20:17:17.476500Z

I see that it is still in alpha. Do you know anything about whether it will continue to be developed?

borkdude 2020-10-31T20:17:28.476900Z

I don't know

Test This 2020-10-31T20:17:41.477200Z

Okay thanks!

borkdude 2020-10-31T20:18:04.478200Z

I believe it was funded with Clojurists Together money at some point not long ago

seancorfield 2020-10-31T20:18:05.478300Z

https://github.com/aleph-io/aleph/issues/539

Test This 2020-10-31T20:19:45.480700Z

Thank you @seancorfield

borkdude 2020-10-31T20:19:53.481300Z

It's a shame that some popular projects like http-kit or aleph lean on one or two maintainers and when they change jobs the project is pretty much stalled? But I guess that's how open source software in a smaller ecosystem works...

borkdude 2020-10-31T20:20:48.481900Z

Thanks!

seancorfield 2020-10-31T20:22:26.484Z

@hiredman Did we look at Aleph before starting down our own path with Netty/interop? Or did we just go straight to netty-socketio because that was a requirement imposed by our client's needs? I think the latter, but I can't remember how much exposure you've had to Aleph?

nivekuil 2020-10-31T20:36:26.485400Z

Ztellman does seems to intend to ship a 1.0 of aleph as of last week, so the alpha label is probably oversold https://github.com/aleph-io/manifold/issues/187#issuecomment-716048610

2020-10-31T20:37:52.487Z

Straight to http://netty-socket.io, I haven't used aleph

seancorfield 2020-10-31T20:38:41.488200Z

Given how many Contrib libs used to be 0.x.y or have alpha labels, that aspect would not worry me much in the Clojure ecosystem. Contrib was all moved to 1.0.0 releases purely to address perception, not because of any functionality or stability issues.

lukasz 2020-10-31T20:38:52.488600Z

Different approach: why not use something like http://pusher.com and let someone else handle the hard parts?

seancorfield 2020-10-31T20:39:03.488900Z

Thanks @hiredman

borkdude 2020-10-31T20:49:59.490400Z

I did recently come across a contrib lib that wasn't 1.0.0

seancorfield 2020-10-31T20:50:36.491400Z

Well, t.d.a. is 0.x.y but it's definitely alpha.

Test This 2020-10-31T20:50:37.491600Z

Thanks everyone. Really appreciate all replies. Pusher is expensive for something that has revenue less than $500 per year :)

seancorfield 2020-10-31T20:51:18.491700Z

And clojure.java.jdbc is stable (no longer maintained) so that's 0.7.x (next.jdbc is the 1.0.0 that c.j.j never got)

borkdude 2020-10-31T20:51:20.491900Z

It was probably data.xml: https://github.com/clojure/data.xml

lukasz 2020-10-31T20:51:59.492800Z

We've been riding the free tier for a long time. It's quite generous (unless it changed recently)

lukasz 2020-10-31T20:52:15.493300Z

and there are alternatives, which compete with pusher on pricing, with the same feature set

seancorfield 2020-10-31T20:52:15.493400Z

Yeah, that maintainer hasn't cleared a 1.0.0 release yet. I think Alex was talking to him about it.

seancorfield 2020-10-31T20:56:43.494500Z

Herwig hasn't updated data.xml in a year and a half at this point tho'... 😞

Test This 2020-10-31T20:56:47.494800Z

I think they have 100 concurrent connections limit for the free tier.

lukasz 2020-10-31T21:01:25.495500Z

Depending on your architecture and the application, that's technically 100 concurrent users

lukasz 2020-10-31T21:02:31.496Z

https://www.pubnub.com/pricing/ gives you 2x that for free and has friendlier pricing. I have never used them though