Fork me on GitHub
#clojure
<
2021-10-13
>
tstout00:10:37

Has anything ever materialized from Rich Hickey's thoughts regarding limited support for distributed processing? https://groups.google.com/g/clojure/c/OJJL2xq2PGA/m/ASHcRWyGekoJ

hiredman00:10:29

I know that at least at one time datomic used hornetq(renamed to something else a while back) internally, and I would draw a straight line from the mention of a jms and queues there in that email to that (actually I recall rich asking on irc sometime after that email if anyone was familiar with hornetq)

hiredman00:10:07

But nothing ever built into clojure

clumsyjedi03:10:15

In com.stuartsierra.component the following extend-protocol section occurs:

(defprotocol Lifecycle
  (start [component])
  (stop [component]))

(extend-protocol Lifecycle
  #?(:clj java.lang.Object :cljs object)
  (start [this]
    this)
  (stop [this]
    this))
Given this, (satisfies? com.staurtsierra.component/Lifecycle 0) is always true. Is there any other incantation I can use to distinguish between a c.s.component and something else?

dpsutton03:10:17

typically component and others like it are used to create an object graph at startup to run an application. or in tests or the repl to build a version of the application with certain versions of components. The usage of component is usually in one spot and there aren't a lot of code paths that really should handle components and non-components. What problem are you running into?

seancorfield03:10:29

Using satisfies? is often a "code smell" because you're trying to use conditionals instead of polymorphism, so I'm definitely curious as to the use case here @clumsyjedi?

clumsyjedi04:10:11

Really I was just thinking the component maps used in all of my apps could serve as a form of cheap documentation, I could generate directed graphs from the system object

clumsyjedi04:10:05

(def edges (reduce (fn [coll [node component]]
                         (if (component? component)
                           (let [deps (->> (->map component)
                                           (filter (fn [[depk depv]]
                                                     (and (not= depk node)
                                                          (node? depk)
                                                          (component? depv))))
                                           (map key))]
                             (apply conj coll (for [dep deps] [node dep])))
                           coll))
                       [] SYS))

clumsyjedi04:10:34

I would really like it if that filter on line 4 could exclude stuff that's not an instance of c.s.component

clumsyjedi04:10:49

Not a big deal, if it can't be done I can find another way 🙂

seancorfield04:10:31

@clumsyjedi Well, anything can be in the system map and it might implement the protocol via metadata. That's a deliberately design decision, so that start and stop are identity functions on anything that doesn't override them. Components can be functions, for example.

seancorfield04:10:05

A hash map can be a component with no specific lifecycle too, but it can have dependencies (something like a function can implement start/`stop` but can't have dependencies).

Jakub Holý (HolyJak)14:10:18

Hi folks! Any idea where to pose questions about the clojure/java.data library? Namely it seems unable to produce Properties with data, which I think should be supported:

(require '[clojure.java.data :as j])
(j/to-java java.util.Properties {"a" "1","b" "2"})
; => {} ; = empty Properties
(Of course it fails, since Properties have not constructor taking a Map). So I guess I would like to open a PR to add a defmethod that handles the pair Properties APersistentMap . Should I? How? Thank you!

Alex Miller (Clojure team)14:10:24

you can ask questions on https://ask.clojure.org with category Contrib libs / java.data

Alex Miller (Clojure team)14:10:03

jiras will be made from questions there if needed

Alex Miller (Clojure team)14:10:40

if you're interested in providing patches, that is the same contributor process as for Clojure or other contrib libs per https://clojure.org/dev/dev#_becoming_a_contributor

👍 1
🙏 1
1
Joshua Suskalo14:10:10

Is there a tool available at the moment like macroexpand that shows expansions of :inline? Or should I just call the inline function directly and validate the result that way?

Alex Miller (Clojure team)14:10:14

well other than the compiler of course :)

Alex Miller (Clojure team)14:10:38

the expansion is in the calling code's bytecode so that's the best place to verify such things

qqq18:10:04

Is there a channel here for people running Clojure on more than one machine server side and the machines are stateful, i.e. not the 'stateless layer that converts http requests to db transactions' ?

vemv19:10:53

#architecture?

lukasz19:10:27

there was but gets rebooted constantly and the state is lost :drum_with_drumsticks:

Muhammad Hamza Chippa20:10:51

I have a .sql file which contains this code            create table if not exists users (
    id integer primary key,
    first_name text not null
);

insert into users (first_name) values
  ('Jerry'),
  ('Jenny'),
  ('George'),
  ('Johanna'),
  ('John'),
  ('Anne');
is there any way to load .SQL file in .clj file ?

p-himik20:10:54

slurp if you want to get its contents as a string - just as with any other text file.

🙌 1
Kelvin21:10:40

Also if you want to use the SQL commands as Clojure functions (rather than just keeping them as strings) you can use https://www.hugsql.org/.

🙌 1
Muhammad Hamza Chippa13:10:50

I implemented HugSql , worked lie a charm

zane21:10:58

Is there anything other than AOT compilation that might trigger protocol-not-implemented errors?

No implementation of method: :<method> of protocol: #'<protocol> found for class: <class>

hiredman21:10:49

weird namespace loading

hiredman21:10:15

which i guess basically just comes down to multiple loading

zane21:10:09

I figured it was something like that seeing as I've only ever encountered this error either because of AOT or reloading at the REPL.

zane21:10:20

But I'm not really sure how that could be happening here.

zane21:10:34

In this case I get that error even when running the repro code as a script.

zane21:10:56

The protocol is in a git dependency if that makes a difference.

hiredman21:10:33

and really aot and reloading end up being sort of the same root cause, in the reloading case you have the same protocol defined multiple times, in the original and the reload, in the aot case you have the same protocol defined multiple times, once in clojure code and once in jvm byte code

hiredman21:10:21

how is the protocol extended to the object/type?

hiredman21:10:45

is it a deftype/defrecord and inline, or is it via extend-type or extend-protocol?

zane21:10:21

The former.

hiredman21:10:43

do you mind sharing the name of the dependency if it is open source?

zane21:10:49

It's not, sadly.

zane21:10:57

Actually, wait. The protocol might be.

zane21:10:15

Darn. No. Neither are.

hiredman21:10:37

check to make sure the dependency is properly extending via the protocol and not via an interface

hiredman21:10:32

that can be tricky to determine, but the red flag is if the dependency is using import on something with the protocol's name

zane21:10:21

It's requiring the protocol, looks like.

hiredman21:10:27

if the protocol is coming it from a dependency of your dependency, then that transitive dependency might the source of the issue, is it a maven dep? if it isn't well packaged it might have been aot compiled

zane21:10:43

The dependency is a git dep of a private repository.

zane21:10:51

Perhaps cached files somewhere?

zane21:10:59

We tried blowing away ~/.gitlibs.

hiredman21:10:16

does (-> obj class supers) at the repl show a type with the same name as the protocol?

hiredman21:10:13

when you look at the code of your dep, are you looking at the same git sha as you are depending on?

zane21:10:27

We compared the SHAs in clojure -Stree.

zane21:10:31

If that’s what you mean.

hiredman21:10:43

compared to what?

hiredman21:10:30

I just mean that when you are reading the code of your dependency to try and figure out how it is satisfying the protocol, are sure the code you are reading is the same version as what you depend on

hiredman21:10:07

since it sounds like you have a relatively deep git dependency tree, I would watch out for the same git dep being pulled in with different coordinate names

hiredman21:10:31

which might cause you to have multiple versions of a dependency on the classpath

zane22:10:10

> compared to what? Compared them to each other. The dependency appears more than once in the tree, with :use-top next to one of them.

hiredman22:10:26

yeah, I am not talking about comparing the tree, it sounds like you are looking at the source of the dependency, so I am suggesting making sure the version of the source you are looking at matches the version you are using (e.g. you are not looking at master but using a version from a month ago)

Alex Miller (Clojure team)22:10:38

the key is usually that you want to ensure you load/compile the ns that defines the protocol first, before any ns'es that have protocol implementations.

zane23:10:42

This ought to happen automatically assuming that the namespaces that have protocol implementations require the namespace that defines the protocol, right?

Alex Miller (Clojure team)23:10:08

yes, the problem is with a reload later that redefines the protocol

Alex Miller (Clojure team)23:10:26

see https://clojure.atlassian.net/browse/CLJ-1544 for a lot of history and info on how this manifests

Alex Miller (Clojure team)22:10:26

if you -Spath, that should umambiguously show you which lib/sha is being used

kenny23:10:18

Does anyone happen to know if all directories specified in -XX:HeapDumpPath must exist prior to the heap dump getting created?

Jakub Holý (HolyJak)09:10:53

I would ask e.g. at StackOverflow, this is more of a JVM question than Clojure so you might get better response rate there

kenny23:10:03

Related: does-XX:OnOutOfMemoryError get executed before or after the -XX:+HeapDumpOnOutOfMemoryError heap dump is written?