This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-20
Channels
- # announcements (1)
- # asami (6)
- # babashka (21)
- # beginners (19)
- # calva (44)
- # circleci (3)
- # clj-http (3)
- # clj-kondo (44)
- # clojure (24)
- # clojure-australia (1)
- # clojure-czech (1)
- # clojure-europe (50)
- # clojure-france (5)
- # clojure-germany (1)
- # clojure-nl (2)
- # clojure-spec (8)
- # clojure-uk (8)
- # clojurescript (161)
- # datomic (4)
- # fulcro (7)
- # graalvm (8)
- # heroku (4)
- # lambdaisland (4)
- # lein-figwheel (5)
- # lsp (48)
- # malli (21)
- # meander (15)
- # off-topic (35)
- # polylith (2)
- # re-frame (21)
- # react (22)
- # reagent (13)
- # reitit (6)
- # remote-jobs (1)
- # reveal (3)
- # ring (3)
- # shadow-cljs (37)
- # testing (2)
- # tools-deps (10)
- # vim (18)
- # vrac (1)
- # xtdb (17)
Hi all. Is it possible to use an alias in a git coordinate in deps.edn? This impacts the way I structure my projects and git repositories. I’m increasingly finding use of deps permits greater modularity - and increases my ability to use a single repository for different purposes - e.g. via aliases - so that repository can be used as a library or a standalone domain service. That’s instead of having two repositories ‘my-cool-library’ and ‘my-cool-server’, I have ‘my-cool-project’. This works really well. e.g. see my https://github.com/wardle/clods service - which can be run as a HL7 FHIR server or simply embedded as a library - and in the latter’s case not drag in dependencies. But, there’s one snag. What if I want to use some of the server code (e.g. some ring handlers) in another project? Is it possible to reference an alias when using a git coordinate? I cannot see that it is. So the options are 1. Build a maven package for the different aliases 2. Use separate code repositories ‘-library’ ‘-server’ . 3. Ask whether others might think referencing an alias (or aliases) to configure what is included in a git coordinate in deps.edn might be useful? Or am I doing this wrong?
To explain: I’m working on assumption that the repository is business domain orientated - and the aliases are technology orientated. It means greater composability and ability to flex/adapt eg spin out a dependency of a wider project to its own managed service vs use as a library when starting out. So being able to slice and dice along what are orthogonal boundaries is helpful. For example, I am building a graph API across multiple repos - but the resolvers should logically be in the repo to which they relate - I combine the graph resolvers or I combine as libraries. But the core library shouldn’t drag in dependencies on graphs as that’s just one prism through which to view that domain. Having a tiny ‘xxx-graph’ repo is IMHO worse than a graph alias which switches on that “prism”.
Thanks! Didn’t see that. I’ll ask there.
is there some standard HTTP request timeout built in to the ring-jetty-component, or underlying jetty server? i'm experimenting with some long lived requests, but the server (which runs jetty via @weavejester's ring-jetty-component) boots my requests before any timeout I've actually programmed in happens
i'm reading clj-http docs on async requests and a bit unclear on whether sending a request with :async true
will still block the calling thread or not?
experiments with sending many requests in a go block suggests it does, only 8 can be waiting at a time
^ disregard this, it returns a CompletableFuture
which is indeed blocking. i'll have to run this on a separate thread pool
The docs on GitHub says it returns an Apache BasicFuture. Are the doc wrong or are you not using clj-http?
Hey fam, qq — is there a more idiomatic way you’d suggest writing this:
(defn wrap-around [tokens i]
(let [left-el-idx (dec i)
right-el-idx (inc i)]
(concat
(take left-el-idx tokens)
(list (list (nth tokens i)
(nth tokens left-el-idx)
(nth tokens right-el-idx)))
(drop (inc right-el-idx) tokens))))
(comment
(= (wrap-around '(neg 3 * 2 + 1) 2)
'(neg (* 3 2) + 1)))
(basically, given a list, i want to update a part of a list, to wrap, a range of inner elements)
the code would be much more readable if you used [x y z]
instead of (list x y z)
(concat (take ...) [[(nth tokens 1) (nth tokens ...) (nth tokens ...)]] (drop ...))
I think using split-at
might help too?
(defn wrap-around [tokens i]
(let [[left right] (split-at (dec i) tokens)
[l t r & right] right]
(concat left [(list t l r)] right))))
https://gist.github.com/stopachka/4957d20625f689a30df68c6108855e0b#file-play-clj-L66 ^ more context friend challenged me to write a “natural language calculator” of sorts in clojure. He thought our immutable data structs would make it harder to do…will show him >:)