This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-28
Channels
- # aatree (1)
- # announcements (1)
- # beginners (18)
- # boot (12)
- # cljsjs (1)
- # cljsrn (6)
- # clojure (358)
- # clojure-japan (1)
- # clojure-russia (69)
- # clojurescript (20)
- # core-async (32)
- # cursive (6)
- # datomic (57)
- # devcards (3)
- # dirac (2)
- # editors (8)
- # emacs (6)
- # juxt (1)
- # ldnclj (4)
- # luminus (2)
- # om (91)
- # om-next (2)
- # onyx (11)
- # reagent (7)
mpenet: boorad: awesome, thanks for the input
can’t say enough about the db… they seemed to have gotten transactions correct, and AQL is a good doc/graph query language
I’ve just started with emacs and cider. Out of the box expand-region seems to have no shortcut assigned. does cider use something different for structural selection?
what do people use to do authentication/authorization in clojure these days? I see friend and buddy being quite popular choices. Any personal recommendations?
yeah, looks like it’s way better documented than friend is, which is kind of important to newbie
Friend seems to do more things for you—I like that it has integrated OAuth workflows, to bounce the user to Facebook/whatever for login. I just couldn't figure out how to use it for my API-request-only auth. I'm sure it's not actually hard, I just couldn't load it into my brain. Buddy, on the other hand, was a snap. Granted, I cribbed heavily from http://luminusweb.net/docs/security.md.
Hello everyone
I’ve been struggling the last 2 hours to get a(ny) HugSQL statement running. I’m using Conman and Migratus to connect and configure a Postgres DB. Postgres seems to be configured correctly, since lein run migrate
works. However executing any generated form from HugSQL results in an IllegalArgumentExeption
with db-spec mount.core DerefableState is missing a required parameter
.
I have run out of ideas what that parameter might be and where to fix it. Can you guys help me out with a hint, please?
@dm3: I have just realised that the problem only exists within lein repl
and the Emacs Cider Repl. I didn’t bother to check in the web app served by lein run
.
Pasting all code would be too much, but I’m getting the same error when just trying the example Luminus Guestbook application. There all code is most likely properly set up and I’m still getting the same error in the REPL: https://github.com/luminus-framework/guestbook
@mostr another +1 for buddy
munen: that error is very much like the one clojure.java.jdbc throws is you pass the wrong thing in for it's "db spec" parameter, where 'mount.core' seems like the wrong thing being passed in, are you passing a symbol in to java.jdbc somewhere?
Why does assoc-in
not support more than 3 args similar to assoc
?
@john.care: cider uses paredit for structural stuff
@hiredman: I’m leaving the facilitation of the actual connection to Conman which in turn refers to mount.core. I’m not directly communicating with jdbc.2 My Code looks very similar to this: https://github.com/luminus-framework/conman#defining-queries
@hiredman: Interesting enough, I have realised by now that the actual code works fine when run in lein run
. It’s just lein repl
and Cider Emacs that do not work. Which is kind of unfortunate.
@hiredman: Since it works in lein run
, I think it’s probably less about the code then some environmental issues.
But I’d gladly pastebin the stacktrace. Mom.
This is the trace I’m getting for all HugSQL forms. My guess is that it wants an explicit connection passed in.
`db-spec [email protected] is missing a required parameter``
@martinklepsch: there's a ticket for that http://dev.clojure.org/jira/browse/CLJ-1771
some an instance of mounte.core.DererableState is being passed in to clojure.java.jdbc as a db-spec
@alexmiller: neat, should've checked
mount is a sort of component like system, right? so mount.core.DerefableState must a component, so somewhere you have a component that contains a db-spec, and instead of pulling the db-spec out and passing to the database code (hugsql or java.jdbc) you are passing the component in
Do any of you know how, or is it not possible in clojure by design, to expand a symbol to a function name? Example: (defmacro x [func & args]
(pkg/@func @args))`
hiredman: Thank you for your help! You are certainly right in that the wrong thing is passed in. However, I do not get why there should be anything passed in at all. I’ve been stuck for 6 hours without fix and it’s getting late. I’ll try some sleep before getting back to it. The help is much appreciated!
hiredman: Oh my, I have a solution!
If I manually execute (mount/start #'issue-tracker.db.core/*db*)
, then I can start HugSQL queries like (db/get-user {:id "1”})
.
Still.. I can find no mention of this need in the docs. You brought me on the right track for a manual solution, though. That’s good enough for now. It’s much appreciated, thanks!
@clintm: you probably want 'resolve'
@munen: take a look at (try) the mounted
luminus guestbook branch: https://github.com/luminus-framework/guestbook/tree/mounted it should work without you manually starting db, it should make it to the release/master soon
@munen Someone had a similar issue here: https://forums.pragprog.com/forums/387/topics/14104
I just don't understand why people use mount, I must be missing something, its model of each namespace as a component, with state as a global thing in a namespace(maybe I am mistunderstanding this), just seems bad, like sticking (def state (atom {})) in every namespace would be
you can only have a single instance of these state variables per clojure runtime, and it is visible to any and all clojure code, right?
and there are plenty of reasons you might want more than one connection to what ends up being the same database
I see no reason why you wouldn't want to centralize code that accesses an external resource
you structure your app in such a way as to have to logically distinct databases, eahc having their own "connection" but in production your ops team decides to use one database
if you want to test running a cluster of your server, if you don't use global state you can run multiple copies in the same jvm, with global state you cannot
I am kind of surprised, are you seriously argueing that global state in an app is a good thing?
I meant that you should use lein profiles to specify a separate configuration for your test profile
so if you have a problem with the mount approach, then could you please articulate it
the problem with global state is generally that it ends up being being difficult to track in the application
it is hard to articulate an objection to something that I think flies in the face of functional programming since the invention of lexical scope
passing your state around in a global var that's referenced everywhere as you do with component isn't any different conceptually
no, I mean, I have used and worked on systems that didn't have a way for different parts to keep state outside of (def foo (atom {})) and it was terrible
in fact I've seen it make things far more problematic, because now your entire app depends on the state being available
writing large test suites, ok, which bits of global state where need to be written and set up for this test
the whole point of using a functional language is that you only deal with state at the edges of your application
but those are predominantly dealing with IO, and have no actual business logic in them
with mount, you don't need your external resources for testing vast majority of the time
yet, I've seen many component based applications where state was passed around all over the place as the system map
and none of the application could be tested without external resources being available
at my last job, our largest codebase, predated component, mount, whatever, and it was largely written as just a bunch of namespaces, and if they needed state the had to use some kind of global mutable thing. whenever the opportunity for a new project came up, no one chose to do that again
and just because you saw a mess with global vars, doesn't mean global vars were the inherent problem
same as if I saw a mess made with component, it's not necessarily component that's at fault
however, if you understand why global state should be isolated then you can do that equally easily with both monut and component
If I can’t run multiple instances of my system in the same jvm, I think that’s a design problem
I am not saying global vars are a problem, clojure vars are global, I am saying a global atom is bad
my experience is that having a namespace that represents the resource is a very clean way to isolate stateful components
but I have definitely written tests, where I wanted to observe how multiple instances of a server interacted together
however, you said that you don't understand why people use mount, and I'm explaining my rationale for using it
there are trade offs right, depending on whatever, running each an its own jvm may be cleaner, but is that fast enough to run as part of your regular test run, how painful is it to maintain the clojure.test code to do that
yogthos: yeah, I am just kind of shocked, like if I saw code in a code review that had (def foo (atom {})) in it, I would require a lot of explaining
in fact I would argue that if you need access to resource to run mosts tests, that's a problem with the deisgn
the rest of the application shouldn't be aware of the details of where the data comes from
if you pass parameters from your business logic, you've coupled your business logic to the resource
and if fact the person that passes me an A, maybe have 100 different As to choose from, or may just create and destroy one on the spot
I'd much rather have a shallow layer that deals with IO that sits around the core business logic that's resource agnostic
sure, but code that takes parameters is by definition less coupled than code that doesn't
the only limitation is that you can't run multiple instances inside the same jvm, if that's a requirement then mount is a bad fit, if it's not then it's perfectly fine
I've been working with Clojure for about 6 years now, and I haven't seen that be a requirement yet however
@hiredman, @donaldball:
> if you want to test running a cluster of your server..
> if I can’t run multiple instances of my system in the same jvm, I think that’s a design problem
> it cannot be local, you cannot have your own copy..
in those rare cases (the only one I know of is "running tests in the same dev REPL") you *can*: https://github.com/tolitius/yurt
but learning how people use mount, I see that there is no shortage of REPLs in that one use case. besides, running something like boot watch speak test
in another REPL is great regardless of whether you using mount or whatever
but isn't this just piling complexity (managing multiple clojure runtimes) on as a bandaid to a problem you wouldn't have to start with, with out global state?
I like it when arguments are provided (outside in), not discovered (inside reaching out)
my view is that you should be able to take the business logic and package it as a library
https://gist.github.com/hiredman/27733 is the earliest clojure code of mine I could find, from 7 years ago, anything earlier is likely lost to lisppaste
and I don't see how coupling your business logic to your resources makes the problem any better
I've lived a war story of trying to remove Korma (sql) from a system over a year or so... I'm afraid mount
will lead to similar situations, because the root cause (ambient global state) is the same
you still have global state for all intents and purposes, and now you can't even test anything without it
yogthos: you have been argueing against coupling business logic to resources, but no one was said you should
if you use monut or component, you're going to have to structure your app in a very similar way to avoid this problem
Huh, that’s not been my experience with component either. The various fns that require (probably protocol implementing) arguments get them explicitly, not the whole system blob.
so now parts of the application that shouldn't care about the state have to take it as a parameter
In my case, a ring handler component got refs to the components needed by the various app handlers and injected them into the requests
when you create a component system, you tell it about the dependencies between components, and each component only has access to the bits you say it needs
lots of people make the system accessible as part of the "reloaded" workflow, but it absolutely is not that way in a prod deployment
look, your app initializes, it creates the system then resources in that system have to become available to functions that use them
yogthos: right, and the way that happens is, you explicitly tell component when creating the system, which components need each other
components reaching their grubby little hands to find some piece of shared state that they didn't tell you that they needed initially is the problem
I'm saying that if you have a piece of business logic and it has to accept any stateful variable as a parameter because it calls a function that uses it then you've got coupling
I want some sort of limits/bounds on the parameters to a subsystem. I hate having to use something that has interactions beyond where it should
if you have a piece of busines logic that has to use some state, but you reading it from a global place instead of passing it in, you've got even more coupling
Fair enough 😉 I was thinking authentication should know nothing about where it comes from
and the core of the application doesn't care one bit where it came from or where it goes
but as I pointed out already, my experience is that I need to do this kind of testing rarely
if you want to vary multiple implementations of components together -- I've found component to be very useful. Sometimes the components have to be a level up from typical logic (e.g. UserStore vs Database)
if I have two different queues, they're conceptually two separate resources are they not?
yes -- how do I instruct the subsystem that consumes a UserStore as to which one it should use?
if my app goes to ldap in production, I would surely want to use the same mock api in tests
let's put it this way, your worst case scenario with mount would be your best case scenario with component
if I had a mock connection in my defstate
then it should behave like a real one right?
you have to know how a subsystem works intimately, to be able to mock it effectively (with mount)
since you don't know how your system works, you can end up with bugs around the edge cases
if you have a mock of a resource that doesn't exactly match how the real one works, that's extremely problematic in my opinion
if you prefer the way component works, it's there and nobody is asking you not to use it