This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-16
Channels
- # announcements (1)
- # aws (11)
- # beginners (3)
- # boot (63)
- # cbus (1)
- # cljs-dev (4)
- # clojure (96)
- # clojure-dev (5)
- # clojure-germany (2)
- # clojure-japan (43)
- # clojure-poland (2)
- # clojure-russia (38)
- # clojure-sg (2)
- # clojurescript (138)
- # clojurex (1)
- # cursive (3)
- # datomic (16)
- # docs (6)
- # emacs (3)
- # events (2)
- # ldnclj (42)
- # off-topic (6)
- # om (384)
- # onyx (122)
- # spacemacs (6)
I have a basic component question. Given the following Database component. When this is started, I would assume that the component has 2 more keys at the end, and that I can access them in stop
. However, the only key I see is what I construct it with (in this case it is uri
). I’m missing something basic here. Any guidance?
(defrecord Database [uri]
component/Lifecycle
(start [database]
(let [{:keys [conn db]} (mg/connect-via-uri uri)]
(info "CREATED CONN: " conn)
(assoc database :conn conn :db db)))
(stop [database]
(let [conn (:conn database)]
(info "KEYS IN COMPONENT: " (keys database))
(mg/disconnect conn)
(dissoc database :db :conn))))
(defn start-database
[uri]
(map->Database {:uri uri}))
it should
@roberto: I would expect :db
and :conn
to be available in stop
, assuming start
has been called...
so, you're doing something like (component/stop (component/start (start-database …)))
?
well, if my assumption is correct, I’ll file an issue along with a sample app. I’m in 0.3.0
by the way
(def comp-app (create-server {:uri mongo-uri}))
(component/start comp-app)
(component/stop comp-app)
yes that is the problem
Reading https://github.com/Prismatic/schema/wiki/Defining-New-Schema-Types-1.0 and experimenting in repl. In first paragraph it mentions "explain is used for human-readable representations of the schema" however (s/explain (schema.core.EqSchema. "test")) returns a list with symbol and "test" (eq "test").. so do they mean developer readable? Im looking for a good way to go from schema validation errors to a bullet point list of issues on the frontend of what needs correcting
side question, any clojurians in bkk atm?
Looking at https://github.com/Prismatic/schema/blob/master/src/cljx/schema/core.cljx#L177
I can't see why (def s2 (s/conditional string? #(> (.length %) 0))) wouldn't work
granted I know I can use (s/pred seq) instead
ignore was misreading..
I’m getting Unable to resolve classname: GoogleCredential$Builder
with that, would I have to explicitly import Builder
?
solved it. needed to (:import [com.google.api.client.googleapis.auth.oauth2 GoogleCredential$Builder])
wei, are you planning to use more java googleapis kit, if its just the oauth2 part you can use clj-http and clj-jwt
This is a sample of how to use clj-http and clj-jwt to do the oauth2 service acc handshake https://gist.github.com/nowprovision/b73e4f38fac13fcc1aab
@nowprovision: thanks for the sample. looks more straightforward than learning google’s specialized library. that said, it’s been done before: https://gist.github.com/terjesb/6783675
also looks like that example requests a new access token for each request. ideally you could use the same one until it expires
its not to be used as is, just an example to get it working, deal with the idiosyncratic of google's oauth2
(rant "Clojure has made me unable to program Java. A colleague suggested the 'adapter pattern' as a workaround for a problem. This would result in an extra class for every domain class. That feels so illegal to me, I could never do that.")
@borkdude: maybe time for a new job if the job is forcing you to do things you no longer want to do ?
@borkdude kotlin? the guy writing cursive clojure claims interops story is extremely good and integration performant and painless (due to not having to compile clojure.main)
@mccraigmccraig: @nowprovision If I was working in a 'product' company I would rewrite the entire application in Clojure. But since we are a services/consulting company, you always have to get the client paying for such a change. Now we have to deal with legacy with every yearly upgrade and RFC.
It's only temporary, but switching between these projects is kind of mind eh .... what is a decent word for it
@borkdude: I used to be CTO of services/consulting company…and that is the reason that statement starts with ‘used to’.
although currently I’m contracting so still doing whatever technology I’m told too!
does anyone know how to generate the code from a WSDL endpoint which appears to be using XML-RPC? complete noob at SOAP/WSDL etc
Hi. How can I start many http-kit server apps and configure routing ports for each one?
We’ve been using nginx as reverse proxy, works fine!
but you can just start multiple apps on different ports
even from within the Clojure app, since it’s basically function to start the HTTP kit handler on a port
yo nice clj ppl; how do i serve a static directory other than "public" using ring ?
@dviramontes: check out https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/middleware/resource.clj
every tutorial out there tells me to use
(wrap-resource "/" "public)
but i need to serve another directory
@tyler: cool i'll check it out
hey mates ! using yesql how could I make one function private? and how could I redefine the function to handle exceptions ?
I just wrapped in another function with a try-catch. but I would like redefine with the exception handler
is there a schema type annotation for functions?
@oliv: for private functions use defn-
for private vars use (def ^{:private true} v ...)
and for the exceptions, look at https://github.com/MichaelDrogalis/dire
and for the private, you can try mixin with-meta
with https://clojuredocs.org/clojure.core/alter-var-root
if that works, don't forget to keep the original's var meta, otherwise you could lose something left by the macro
@ddellacosta: if you look at the canonicals https://github.com/Prismatic/schema/blob/master/src/cljx/schema/core.cljx#L360 there doesn't seem to be one
bensu, that’s what I thought, but was wondering if folks have a way of validation functions
oh, I suppose that works
thanks bensu
I'm running into a strange issue. In the terminal in multiple environments, lein ring uberjar
will correctly compile a jar using ring options set in profiles.clj. But using the Jenkins lein plugin or just executing shell, lein ring uberjar
complains that no handler is set for ring in project.clj. Anyone seen this?
tom, what is set for the jenkins user in profiles.clj or otherwise?
I’ve had to deal with vaguely similar issues recently, and had to set some env vars in my jenkins script/lein profiles.clj
hmm, I would too though actually
if you have an :uberjar profile in your project.clj
curious. 😕
oh, nevermind, not sure about that
not sure if the uberjar profile is passed through by whatever the ring plugin is doing
misread it and saw lein uberjar…
hmm but this would seem to suggest it does: https://github.com/weavejester/lein-ring/blob/17cd6cb3b0cce6b842da1623bb2023326906cbb3/src/leiningen/ring/uberjar.clj#L23-L36
sorry @tom, I’m as puzzled as you