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”.
There is a #tools-deps channel for this
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
Nothing I know about. What exactly happens in your case?
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
it depends on how you use the CompletableFuture
you can attach callbacks to it instead of derefing it
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))))
it's idiomatic to add a docstring
#1 recommendation
oo, nice. Thanks team!
"update a part of a list" not semantic
is this op specific to tokens
or lists of anything?
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 >:)