Fork me on GitHub
#yada
<
2016-09-02
>
dominicm09:09:14

@kingoftheknoll Bit late to this, but an alternative I read about on Steve Klabnik's blog (http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-rest-or-http) was that you should be updating an attribute of the resource, e.g.: POST /instance/2 {:status "restarting"} And then it's up to your application to detect that the status has changed, and react to that (e.g. send the restart command)

lmergen10:09:41

@dominicm i think that is a hateoas approach, and it makes sense, but it’s quite different from what people consider “normal”. it’s a kind of inverted logic that feels almost algebraic

dominicm10:09:46

@lmergen My understanding is that it's REST. And that HATEOAS is just the hypermedia part of REST.

dominicm11:09:07

I'd be interested to know if there's a preferred way to refer to a group of resources in strict REST. Although, I did read in Roy Fielding's dissertation that a resource can be a grouping resource, so it may be acceptable to have POST /instance?q=1&q=2&q=3 {:status "restarting"} But I wouldn't swear to it

dominicm11:09:59

@lmergen RE the normal consideration, in the grand scheme I agree it's outside that, whether that's for a good reason is questionable. I'm not sure my suggestion is outside that in the specific domain though. I'm fairly certain that's how one server management API I've interacted with works. I remember finding it a real pleasure to work.

dominicm11:09:23

Looks like digital ocean works by interacting with an action resource. So you would create a "restart" action resource, with the target id. That's the other option that I think would be fairly REST.

statonjr12:09:09

Use JSON-RPC if that’s what you need/like.

kingoftheknoll12:09:28

@dominicm: that's an interesting idea and had a nice declarative "make the resource look like this" feel. However I wonder how a factor of time would work into something like this. For example, stop all servers or stop all servers at 8pm. An extension of that thought is working with a cloud API I don't "own" the state. So you're always in a state of partial staleness and every mutation is actually an intent to mutation with a later harvest confirmation that it worked.

malcolmsparks12:09:47

@frozenlock: I've been looking at your yada/url-for problem (returning nil). Are you wrapping these routes in yada/swaggered? If you are, and tagging this resource grouping with bidi/tag, the resulting TaggedMatch record 'steals' the call to unresolve-handler and fails to delegate to the resources below it. Hence, path-for returns nil. I've fixed this and released a new version of bidi today

malcolmsparks12:09:21

@kingoftheknoll: I think you could POST an action into a calendar. When that time occurs, the action is enacted.

frozenlock12:09:49

Amazing, thanks!

kingoftheknoll12:09:11

That's a clever way of thinking about it

malcolmsparks12:09:13

Essentially all unsafe methods are manipulating state somehow. All state manipulation can be reduced into adding to, modifying, or removing elements from that state. So all state manipulation can be reduced to CRUD. But that doesn't mean we expose db tables as resources one-to-one, rather we create metaphors, logical resources

malcolmsparks12:09:02

@kingoftheknoll that said, there's nothing to stop you defining your own methods along with custom semantics. Yada fully supports that. You can create methods like BREW. See WebDav for examples.

tcoupland13:09:04

made a little type hinting PR for Boyer-Moore-Horspool namespace, made quick the difference for my uploading. Pretty sure it's legit as well! 🙂

malcolmsparks13:09:26

I'll be merging that

mishok1313:09:07

perhaps a stupid question, but what is the best way to add a response header in Yada resource?

mishok1313:09:49

so far I've settled on adding an interceptor that does (assoc-in ctx [:response :headers "header"] "value") but I'm sure there's a better way

dominicm13:09:20

You can do that in a handler too @mishok13

mishok1313:09:37

how would the handler body look then?

mishok1313:09:52

because right now the handler is as simple as {:get {... :response (fn [ctx] "foobar")}}

mishok1313:09:02

ah, return ctx instead of just body

mishok1313:09:12

should have tried that 🙂

dominicm13:09:18

:response (fn [ctx] (assoc (:response ctx) :headers {"header" "value"} :body "foobar"))

dominicm13:09:57

It's not the most obvious unless you're familiar with the idea already 🙂.

eslachance14:09:14

@dominicm so I'm pretty much the only fool trying to develop Clojure apps on Windows is what you're saying in #beginners ? 😛

eslachance14:09:07

I know it's my fault it just irks me that I can't just... have something functional I can tear apart. Both Edge and Hoblon failing and then Luminus' how-to just not giving me a functional project, now I remember the annoyance from last time I tried this.

frozenlock14:09:23

luckyevie : edge looks a little heavy if you are just getting your toes wet. (especially with 'components')

frozenlock14:09:39

How about just bidi/yada/aleph?

eslachance14:09:12

I just looked at yada... Thing is the smaller projects don't have the "I am a noobish noob, feed me a readme that makes this work" sort of thing.

eslachance14:09:40

I don't have a base project so "just add http-kit in there and you're gtg" doesn't cut it - I don't know clojure yet enough to understand where.

frozenlock14:09:14

Yes, that's why I was suggesting going minimal 😛

eslachance14:09:16

I come from nodejs so it's like.. npm install X, copy this script, node file.js and go 🙂

frozenlock14:09:23

Running aleph would be the first step.

frozenlock14:09:53

(And possibly bidi)

eslachance14:09:53

I think that's the biggest issue I've been having with clojure : it feels like the first baby steps are climbing a beanstalk to get to the treasure at the top 😛

eslachance15:09:57

I think this is why I was just asking for... a base project on lein or git that "just works". aleph still isn't that, it requires a tiny bit of pre-comprehension of project structures.

frozenlock15:09:06

I must say that's the feeling I had a few years back when I learned clojure. But back then it was pretty new. Hopefully things are better now for noobs 😉

frozenlock15:09:23

What are you looking to make?

eslachance15:09:25

Don't think they are too much unfortunately! And especially not the plebs like me on windows

eslachance15:09:57

I have a plan for a webapp that, while not exceptionally unique, is much better than the tools I've seen. The experience I have in the software domain related to the project will help

eslachance15:09:26

I mean I don't think anyone would steal this idea but... Let's stick to "it's a responsive, data-driven webapp"

frozenlock15:09:59

Do you intend to use clojurescript as well?

eslachance15:09:24

Ultimately clojurescript, re-frame for the front-end at least

eslachance15:09:43

aka "I don't want to write html direct anymore" :P\

frozenlock15:09:44

Ah great, so Reagent. Then I would suggest you start with https://github.com/reagent-project/reagent-template

frozenlock15:09:01

It doesn't use bidi/yada/aleph, but those can be switched later.

frozenlock15:09:06

This is what I always start with.

eslachance15:09:31

Alright let's see if I can get this up before finishing my coffee and heading to work ^_^

eslachance15:09:08

Oh... bravo reagent-template doesn't start I get a stack trace the size of Atlanta. picard-facepalm

eslachance15:09:28

I should seriously think about at least a linux VM.

mccraigmccraig15:09:41

@eslachance do that, or you will be fighting something you don't really want to fight while you are in noobland

eslachance15:09:07

Ah yes, noobland. The murky depths I escaped quickly while doing node because of my past experiences with JS, and attempt to help other newer noobs traverse on... discord. I don't want to be in Noobland for too long. Noobland sucks.

eslachance15:09:17

Definitely linux VM to start with

imre15:09:30

@eslachance we develop clojure webapps on windows

imre15:09:41

well some of us do

imre15:09:03

same couple of projects, devved on win mac and linux

imre15:09:23

using yada

eslachance15:09:26

Some of us can be forced to heh.

imre15:09:59

that being said I switched from win to arch linux 2 weeks ago and did not regret it

eslachance15:09:04

My friend and colleague did a very nice thing for work in clojure, all in Windows, and with boot

eslachance15:09:25

The issue is I'm still a noob and I can't troubleshoot stuff yet.

eslachance15:09:53

Actually that friend hangs around here too, but generally too busy to teach me

dominicm15:09:17

@eslachance: edge should let you start on windows. The fact it didn't give exceptions is positive. One year ago I was hapi.js all loaded up with Babel, so I understand the shock, its totally a bullet worth biting. 😃

dominicm15:09:29

When you say it was giving 404s, can you give the exact URLs you tried, and 404 page you got? 😃 Copy paste is better @eslachance

eslachance15:09:51

The only issue in Edge is that it failed the first time I ran it, and then yeah I got 404 on all the resources (Except the html itself)

dominicm15:09:31

Oh? That sounds like a good thing to me 😃

eslachance15:09:55

It was almost there I guess 😛

eslachance15:09:09

installs boot at work

eslachance16:09:10

I did actually see that page =D I waited a few minutes and reloaded with the same issue though

dominicm16:09:04

Could you search your target directory? Look for edge.js or app.css I think the CSS is called

eslachance16:09:36

currently grabbing deps... please stand by...

eslachance16:09:27

So the first boot, this is what I get (please forgive the ugly output and french errors):

12:05:40.519 [clojure-agent-send-off-pool-0] INFO  edge.web-server - Started web
-server on port 3000
       clojure.lang.ExceptionInfo: C:\Users\lachance\.boot\cache\tmp\data\devel\
edge\dq0\-rcsl8f\edge\selmer.clj: Le processus ne peut pas accÚder au fichier ca
r ce fichier est utilisÚ par un autre processus.

    data: {:file
           "C:\\Users\\lachance\\AppData\\Local\\Temp\\boot.user3118914793701141
329.clj",
           :line 31}
java.nio.file.FileSystemException: C:\Users\lachance\.boot\cache\tmp\data\devel\
edge\dq0\-rcsl8f\edge\selmer.clj: Le processus ne peut pas accÚder au fichier ca
r ce fichier est utilisÚ par un autre processus.

      file: "C:\\Users\\lachance\\.boot\\cache\\tmp\\data\\devel\\edge\\dq0\\-rc
sl8f\\edge\\selmer.clj"
    reason: "Le processus ne peut pas accÚder au fichier car ce fichier est util
isÚ par un autre processus.\r\n"

eslachance16:09:46

the error is "the process cannot access the file because it's used by another process"

dominicm16:09:07

Odd. Especially as it compiled on your other machine. I'll dig in 😃

eslachance16:09:18

No it did the same thing on the other machine, the first time

eslachance16:09:26

starting it the second time does not bring up this error

eslachance16:09:39

(so maybe it doesn't "compile" the second time?)

dominicm16:09:27

The resources might not get built, if files that look like they are built are in the cache. Also, could you click onto one of those urls? The 404 page it gives will be very informative

dominicm16:09:00

We might need to do an initial clearing of the cache, but I'll clear up my first idea first 😃

eslachance16:09:14

{status: 404, message: "Not Found", id: "d8dcd569-4a47-4faf-bc1f-da73f909f3ed",…}
error
{error: "clojure.lang.ExceptionInfo: {:status 404}", data: "{:status 404}"}
data
"{:status 404}"
error
"clojure.lang.ExceptionInfo:  {:status 404}"
id
"d8dcd569-4a47-4faf-bc1f-da73f909f3ed"
message
"Not Found"
status
404

eslachance16:09:35

oh my copying errors from the console isn't pretty heh.

dominicm16:09:25

That's okay, I'm pretty sure that's yada, which is what we want 😃

eslachance16:09:46

Actually opening the file in the browser instead of looking at network is more informative

eslachance16:09:49

clojure.lang.ExceptionInfo:  {:status 404}
	at clojure.core$ex_info.invoke(core.clj:4593)
	at yada.resource$eval26538$fn__26539$fn__26540.invoke(resource.clj:121)
	at manifold.deferred$eval7307$chain___7328.invoke(deferred.clj:860)
	at manifold.deferred$chain.invoke(deferred.clj:929)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at clojure.core$apply.invoke(core.clj:632)
	at yada.handler$handle_request_with_maybe_subresources.invoke(handler.clj:120)
	at yada.handler$handle_request.invoke(handler.clj:168)
	at yada.handler.Handler.request(handler.clj:223)
	at bidi.vhosts$make_handler$fn__20669.invoke(vhosts.clj:160)
	at aleph.http.server$handle_request$fn__19056$f__6628__auto____19057.invoke(server.clj:154)
	at clojure.lang.AFn.run(AFn.java:22)
	at io.aleph.dirigiste.Executor$Worker$1.run(Executor.java:62)
	at manifold.executor$thread_factory$reify__6510$f__6511.invoke(executor.clj:36)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.lang.Thread.run(Thread.java:745)

dominicm16:09:35

So, could you delete .boot/cache? After stopping edge.

eslachance16:09:01

alright, and re-run boot dev?

eslachance16:09:21

oh would you look at that! colors! fonts ! 🙂

dominicm16:09:33

Sounds like boot just ha[sd] cache building problems. But a quick rm always helps

eslachance16:09:02

I guess maybe I should report on github as reproducible on 2 machines, and the fix

dominicm16:09:34

@eslachance I'd try bothering the guys in #boot first, just to see what they know. Boot is exactly like gulp, and the fact we have a handful of boot-related dependencies makes it hard to know who exactly to blame!

dominicm16:09:11

Though, I just realised you may have meant on the edge repo, in which case definitely would be helpful to have it on there actually!

eslachance16:09:24

Yep, put it on the edge repo 🙂

eslachance16:09:51

If I was my friend oahner I'd probably dig into the issue for an hour and find the exact cause before PRing a fix (like he has done for an issue about boot on windows in the past!) but I'm not that kind of genius 😛

dominicm16:09:48

@eslachance When I started clojure I thought like that (the super geniuses fix everything!) Turns out you don't have to be a super genius to help in the Clojure community, I'm not sure if it's the simplicity of the language, the active community, or what. But it's very possible, and definitely not just the super geniuses!

eslachance16:09:40

It actually turns out that I'm pretty good with node and the discord.js bot library, and I've been helping people a whole lot in the last 3 months while learning so much more than I thought I would.

eslachance16:09:14

That confidence of being called "Proficient" and even writing a gitbook to help other new users (I'm a tech writer by trade) really, really helps. Node was a stepping stone. Now on to the real stuff.

dominicm16:09:52

That's pretty similar to what I've dug myself into actually. I think you'll find yourself able to feel proficient in Clojure very quickly, and fixing small bugs here and there for things.

eslachance16:09:39

That's the plan. I've just been sitting in front of a mental wall for a while in regards to Clojure. I just gotta get passed that block.

eslachance16:09:14

Right now though, happy to take the first steps in here - I really, really hate being a noob and feeling like one. I guess at least I'll never ask to be spoonfed 😛

dominicm16:09:20

Yeah, there's definitely a little climb.

eslachance16:09:25

Once I've wrapped my head around the structure of a project, and understand the basics, I'll most definitely appreciate a google search or a code example in a repo, rather than being given the answer straight-up

eslachance16:09:27

Watching these kind of videos is what got me really, really, really interested in clojure

eslachance16:09:38

That and some coffee break conversations with oahner.

eslachance16:09:05

I think "Atoms" and other awesome terms and I go "holy shit I wanna use those"

kardan16:09:43

I’m playing a bit with Yada. & now I wonder about what to do with “resource assets”. With bidi I used ResourcesMaybe at some point. Should I use that directly or something in yada?

kardan16:09:02

Maybe there is an example I missed..

kardan17:09:10

I made a typo, ignore me. ["assets" (->ResourcesMaybe {:prefix "public/"})] worked fine!

dominicm17:09:31

@eslachance: I got a copy of the stack trace on my girlfriend's windows machine so it's definitely reproducible. Gonna try and minimize the case. Might be maven caching related

dominicm17:09:56

I also got a security prompt on the first run, did you?

eslachance17:09:12

I got a firewall prompt for Java.exe but that was it

eslachance17:09:35

Mind you that's a bit ridiculous because this is a work machine behind a corporate firewall, I shouldn't have a local one 😄

eslachance17:09:51

Oh btw I did report it on https://github.com/juxt/edge/issues/18 if you didn't already see that.

eslachance17:09:12

oh look, Slack likes to show my face just like Discord. yay. 😒

dominicm17:09:12

I did, yep, thanks!

malcolmsparks18:09:45

The Clojure mountain is very hard to climb but the view from the top is worth the hard work. We're trying to help by making Edge a smooth introduction to real-world clojure. I hope the use of 'component' doesn't hurt too much. All feedback on Edge is really helpful. Right now yada isn't as accessible as it should be and your help in improving the upramp is truly appreciated.

eslachance18:09:23

@malcolmsparks I have to dig through the examples to really be sure I understand stuff - but the way I see it that build error is very minor. Edge attempts to be a helicopter that gets me partway up the mountain and the only problem is that the control stick jiggles a bit on takeoff 😉

malcolmsparks18:09:12

Yes. I've never tried but I understand helicopters are hard to fly :)

eslachance18:09:30

Not in GTA V 😂

malcolmsparks18:09:37

@eslachance Did you get edge working eventually?

lmergen18:09:22

I think Edge is a really good base. I've stripped out some things related to cljs and we're pretty much using that as a base for our microservices.

lmergen18:09:38

I think it's actually achieving the same goals as luminus, is it not ?

malcolmsparks18:09:14

@lmergen Yes, similar goals. Stripping it of things you don't need is the point

malcolmsparks18:09:01

Great to hear it's helped provide a foundation for you

lmergen18:09:27

It's good, and provided a lot of sane defaults for structuring services. The whole component / aero / boot integration is absolute gold.

lmergen18:09:55

Not that it's difficult to do yourself, but rather as a "this is how it's done" guidance.

malcolmsparks18:09:25

It's deceptively difficult actually. Edge was in the making for over a year

malcolmsparks18:09:31

But there's lots of improvements in the pipeline

lmergen18:09:24

Yes, I can understand that. I guess that's a signal that you're doing something right, if it looks simple.