Fork me on GitHub

looking at the code I recall it being super fun to work on, so you know, maybe do it anyway


Hi all…just a quick note that I’m pleased to announce that we’ve open-sourced our tool “protojure”, which is native support for protobuf/grpc for Clojure:

👍 16

There's still a step for generating clojure code?


Yeah, it works like any other protoc plugin, but adds “--clojure_out” to the mix.


by default, it will only generate the protobuf definitions, but you can also optionally add grpc-server or grpc-client generators by specifying an argument, e.g. “--clojure_out=grpc-client:path/to/output”


There is some preliminary documentation available on the GH page. We will be enhancing this moving forward.


How difficult would it be to do it without generating source files using this code? I've always thought that an interpreter would be more useful in clojure as clojure is very source-oriented. For example this would be incompatible with certain styles of deps.edn local/git dependency


well, its not impossible, but it would be a fairly major change from the way its currently designed. For one, it depends on the protoc compiler to parse all the .proto files and generate the AST, which protojure consumes to generate its output


that said, I have a similar project in Hyperledger which does its own proto parsing via Instaparse


so I can see of a pure clojure lib that parses protos directly at runtime


but thats not how Protojure works today: Protojure works like pretty much 99% of the rest of the protobuf/grpc language support works: as a plugin to protoc that generates native code


The closest thing I have seen to what you describe is using protobufjs via cljs interop


(which is quite slick, I agree)


Ah. Having protoc do the ast parsing explains why I don't see this get often.


but for me, a proto compilation step is quite natural flow


if you are curious, this is another project I have:


that one can do pure clojure parsing of protofiles


so, a blend of the two would get to what you are looking for


> Ah. Having protoc do the ast parsing explains why I don’t see this get often. Yeah, the ecosystem is definitely structured this way


I do think it would be quite possible to leverage the helper routines I have in protojure/lib for a runtime implementation


its primarily a matter of doing the parsing and then interning the symbols dynamically


in any case, I understand your usecase and it interests me as well…however, competing priorities didn’t allow any time to be spent on it


perhaps a future PR


When I need protobufs next I'll look into it!

👍 4

Like sql => like hugsql => like hugwhere, yes, you do!

🚀 4

can one consolidate the two let steps into one?

(let [the-map (->> x
                                                               (group-by reader-conditional?))
                                                  [normal-forms reader-conditionals] (map (partial get the-map)
                                                                                          [false true])
...I guess I'm asking for a values-at function, but want to have a handy pattern doesn't require me to introduce that dependency whenever needed. i.e. do the thing inline within the ->>


@vemv you could use map destructuring instead on the result of group-by?



(let [xs [1 2 3 5 8 10]
      {odds false, evens true} (group-by even? xs)]


yes! fantastic, I had forgotten about this one 🙂


I think 90% of my uses of group-by are immediately destructured in this way 🙂

clj 12
Matheus Moreira14:08:45

hello! another question about spec and stest/instrument. the function documentation states that there are some parameters that can be used to override specs or mock stuff (:spec, :stub, :gen, :replace). i am not sure how to use these options in my case.

Matheus Moreira14:08:03

i have a function with two parameters, the second more like a dependency: (defn create-todo [task repo] ...) and the spec definition is:

(spec/fdef create-todo
  :args (spec/cat :task :todo/task
                  :repo :repo/repo)
  :ret :model/todo
  :fn (fn [{:keys [args ret]}]
        (and (= (:task args) (:todo/task ret))
             (not (:todo/completed? ret)))))

Matheus Moreira14:08:07

repo/repo is basically (partial satisfies? Repository) and Repository is a protocol. in this case i suppose i should mock the second parameter, e.g. to pass an implementation that holds stuff in memory.

Matheus Moreira14:08:22

how could i do that when using stest/instrument?

Alex Miller (Clojure team)14:08:23

I'm not sure any of the stest/instrument options directly help you do that

Alex Miller (Clojure team)14:08:23

really you probably want to use a replacement generator for :repo/repo that just always returns your mock impl

👍 4
Lone Ranger18:08:22

is there a way to dynamically namespace functions?

Lone Ranger18:08:57

ehh nvm I'm just being lazy

Lone Ranger18:08:22

hahaaaaaaa... thx ... needed that today


Does anyone know where I could find directions on how to deploy a library (based on deps.edn) to a maven repo (an internal one, not clojars)? Is pomegranate the way to go? Do I need to write the pom file manually?


I have not used these tools, so if you are looking for a recommendation based upon successful use, I would wait for another answer, but mevyn listed on this page might do what you hope:


Oh, how'd I miss that? Thanks, I'll give it a try!


clj -Spom will generate a minimal pom.xml with dependencies but you'll want to expand it quite a bit (then clj -Spom is safe to use again since it will update the dependencies in an existing pom.xml file).


FWIW, we use depstar to build JAR (and uberjar) files from source and the generated/expanded pom.xml file. And then we use mvn deploy to actually push the JAR file to a repo.


The author of mevyn recently said that if depstar had included the pom-reading/manifest-generating logic from day one, they wouldn't have written mevyn 🙂


^^^ That is the answer you wanted to wait for 🙂


Oh, nice. I expected -Spom to overwrite instead of update. I think that'll do what I need. Thanks!