This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-10
Channels
- # announcements (2)
- # aws (11)
- # babashka (11)
- # beginners (22)
- # calva (28)
- # cider (1)
- # clj-kondo (3)
- # clojars (14)
- # clojure (41)
- # clojure-europe (45)
- # clojure-norway (1)
- # clojure-uk (2)
- # clojured (31)
- # clojureindia (4)
- # cursive (5)
- # datahike (15)
- # datomic (11)
- # deps-new (11)
- # events (1)
- # holy-lambda (19)
- # introduce-yourself (1)
- # minecraft (17)
- # music (1)
- # nbb (3)
- # off-topic (37)
- # reagent (6)
- # reveal (3)
- # shadow-cljs (46)
- # tools-deps (8)
- # xtdb (22)
Today I found a use for update-keys
function. Finally.
(user-login-info-by-email [_ email]
(update-keys
(user-login-info-by-email-q
@db-ref
{:email email})
db-to-non-db-attr-names))
This code replaces keys such as :user_name
to :user-name
and the map db-to-non-db-attr-names
contains this:
{:user_name :user-name}
Actually the update-keys
may be faster in some places where I know that the updated map is almost always has less entries than the upadted key count.
Because these are the same operations but rename-keys works by iterating through the renamed key map and not the item itself :thinking_face:
But other than that there is little difference in my current usecase :thinking_face:
Well... I tried. But update-keys
uses transient code at least.
And no, I didn't want to change my keys dynamically. I know what they are.
hi all, has any one used this library for consuming from Kafka? https://github.com/helins/kafka.clj. I could not find an API in it to consume from a partition starting from a given offset. Maybe I missed it?
We’re using kinsky, which is just a wrapper for the java api so you may have more luck there
Looks like you have to use seek https://github.com/helins/kafka.clj/blob/master/src/dvlopt/kafka/in.clj#L559 to specify offset for the consumer
we heavily use kafka from clojure at work and we don’t bother with any of the wrappers. less stuff to learn if you just use the kafka api directly. embrace the platform!
Clojure’s design question: why aren't evaluated symbols always specifying the Var? Which is to say, there’s the issue of referencing a function in a map that's bound to a var (with def
) and then reevaluating the function definition, the map holds a reference to the previous definition, so to make it work intuitively, you use #'
to reference the var instead. I haven’t tried, but i suspect this applies not just to functions but to all types.
I suspect the performance consideration is at play. Every time you call a var, the var is first deref'ed and then the resulting function is called.
Yeah, that is probably the reason. I wonder if it would be possible, with the help of hindsight, to implement it such that there's no deref necessary for vars
in order to allow you to perform repl-driven updates to values there must be a pointer deref in there somewhere. Doing it with vars just makes it controlled and allows it to interact well with the namespace system. I don't think that you could realistically have your cake and eat it too with lower indirection but also more reloadability by default without doing graph tracking to re-evaluate all code that depends on a var when you re-evaluate the var definition.
yeah, i'm not sure exactly. I thought common lisp was able to handle this, but I don't have cl set up on this machine so I can't test it out
The CL situation is actually strikingly similar to Clojure, except that instead of storing values and functions on vars, they store them on symbols, which are interned in CL like keywords are in Clojure. Symbols are container objects that store a value and a function on them and are associated with a specific package, and so in cases where you want to pass a function that will be updated, you just pass the symbol. You then grab the function by calling symbol-function
and then call funcall
on that object.
In places where code doesn't take symbols and just takes function objects you return the function object with #'
and it has the exact same problem as Clojure does with stale definitions.
ah okay, interesting. I thought common lisp did a better job with redefinitions
In general CL it is much more annoying to deal with higher order functions because there's additional ceremony introduced by it being a lisp-2
It does better with object objects, by allowing you to redefine classes at runtime and it will walk the full graph of live objects and change any that are of the old class to be valid (but perhaps unconstructable) instances of the new class.
so because it's interned, when you change the definition of a non-function symbol, the value is propagated?
very interesting, thank you for the information
Yes, evaluating code that refers to a symbol does a lookup the same way as it does in clojure
no problem!
I suspect this would break referential transparency. If you always deref the var, you're sensitive to the var being redefined. Then you're working with references, and not values. And we tend to like values when working with clojure!
More from Rich: https://m.youtube.com/watch?v=-6BsiVyC1kM
So our company had a new dev and while setting him up we encountered something bizarre with his JVM. This does not work for him (for context we're using OIDC and Keycloak for security):
(slurp "")
But this does, where we replace 0.0.0.0
with localhost
:
(slurp "")
What's truly bizarre is that this issue doesn't affect anyone else. Does anyone have an explanation for this phenomenon other than "the JVM router is finicky?"FWIW I wouldn't expect for 0.0.0.0
to work in any context where you make a request, as opposed to making something listen to it (which results in listening to all IP addresses on the host).
But apparently, it can be used, although it's not well defined. So I would use it for requests even if it works on most machines.
> So I would use it for requests even if it works on most machines. You mean not use it for requests?
You can make it work by routing 0.0.0.0 to localhost in /etc/hosts
file, at least you used to - no idea if it's used anymore in macOS/Linux/etc
yeah what's the rationale behind using 0.0.0.0 instead of the loopback address?
IIRC it was because Docker would sometimes fail to expose ports on localhost
instead of 0.0.0.0
. @U06872G6L (who set up most of the Keycloak/OIDC at our shop) likely has a deeper insight into this.
Yeah, because Docker for Mac cannot do host networking, not sure about Windows, so your server running in a container has to bind to 0.0.0.0 for the routing to localhost to work
ah, so it's container shenanigans. Fun.
0.0.0.0 can have multiple meanings - the most common is “listen on all network interfaces”. As they already said, don't use this as a hostne fir requests
Yep, that’s where the confusion came from, it’s strictly for binding, though I’m still not sure why it ever worked on our macs, as we’re not routing 0.0.0.0 to localhost.
Is there a list of all known future clojure-related conferences? IOW, how can I find out where and when will the next clojure conference take place?
https://clojure.org/community/events incomplete list but something that one can call "official"