Fork me on GitHub
Wes Hall01:03:26

@folcon So I just had a look through trying to fathom the lacinia subscriptions stuff because it was on my todo list anyway. One immediate answer is, "if you are not using lacinia-pedastal to serve your graph over the web, then you'll get subscriptions working only with a rather large headache". It looks like most of the real work is done in the lacinia-pedastal library and the parts of lacinia core that handle subscriptions are effectively written as internal APIs. They are not private as such, but are lower level than the execute function that acts as the primary public API for executing regular queries. The entry point for subscriptions, seems to be invoke-streamer inside the com.walmartlabs.lacinia.executors ns, but all of the helpful stuff that execute does, like parsing the query and injecting any variables is bypassed when you invoke at this level. Personally, I think they are desperately missing an execute-subscription top level API, and maybe I will mess around trying to do a PR for this. As it stands though, best thing to do would be to go through the lacinia code looking at how execute works. If you look at how execute prepares a call to execute-query (via execute-parsed-query), then it looks like you need to prepare the context object in basically the same way before invoking invoke-streamer. Though once you do this, you can simply pass your callback function and handle the pushing of any callback invocations down your websocket stream. If you are are using the lacinia-pedastal library, then as far as I can see it should just work, though you do need to "switch it on". This doesn't seem to be documented on the lacinia-pedastal readme (edit: apparently it is in the manual so you have probably seen this) but subscriptions are turned off by default and you need to pass a {:subscriptions true} option when you create the pedastal service map, the same way that {:graphiql true} is shown on the readme. This should start the server listening on /graphql-ws , which, at least according to the docs (I haven't tested it), should behave the same way as Apollo.

Wes Hall01:03:07

TLDR; Just implement polling 😉


Well I’ve been digging into a not quite completed example that someone whipped up, it’s somewhat instructive? Hopefully it will give me enough of an idea of how things work that I can decide whether lacinia is worth jumping into pedestal for… Code is here ->, my current issue is not being sure how I can get session data, and for some reason my com.walmartlabs.lacinia.pedestal.subscriptions keep disconnecting, not that it appears to do anything… Re the session data, I’ve tried implementing this: but the interceptor never set’s the :lacinia-app-context, so I can’t even see if the session info is available to be passed on… I’ve got websockets working at the moment with sente, part of the reason for doing this was to allow the frontend more freedom to specify what it got back from the backend over sockets, so less long polling and more write my own version of graphql for websockets? 😞 Time for bed me thinks =)… I’ll pick this up tomorrow!

Wes Hall13:03:18

I see. Honestly I don't know too much about the client side problems. I am not super happy with the pedestal module for lacinia. I prefer to keep a bit of a closer control of my web tiers. I have a little bit of infrastructure that handles exposing lacinia over the web by only for queries and mutations, had not started looking at subscriptions yet. I might have a play with this. If I find anything useful i'll let you know.

Wes Hall13:03:54

There is, imho, some bad design in all this. It's weird to me that when you do a query lacinia does the main lifting, but when you do subscriptions, lacinia-pedestal does the same lifting.


Thanks =)…


Would be interested to know if you figure something out ;)…


Good Morning!


We got yada hooked up with pedestal streams pretty easily. I think there's an example in edge. @folcon


The work in Lacinia pedestal is mostly to work around the fact there's no content negotiation, JSON generation or good async solution in pedestal. Iirc anyway.


Morning. How is everyone holding up? People with kids doing okay? People living alone staying in touch with other humans via video calls? And everyone in between?


we are managing...

👍 4

Yeah, pretty much. I'm load balancing my kid with my wife during the day. But the latency can be very high given work responsibilities and nap times.


Yeah, we've got school work we're trying to help our son stay focused on. It feels like an immense task, especially when you throw work into the mix. I wonder how different schools are approaching their teaching strategies with the current lockdown situation.


Our child is 3 years old (nearly), so having a "schedule" doesn't quite work (yet), but we have some things we do - like walk with daddy in the morning and afternoon. As for schools, no idea.

👍 4

(wife nap times, not kid nap times 🙂 )


We try and go for a walk each lunch time.


We've been doing exercise classes via YouTube videos. Seems to work well


PE with Joe 🙂


Yup, been doing that too 😂

Jakob Durstberger08:03:06

I live on my own so I have to say it’s been pretty boring 1.5 weeks so far. 😕


Are you joining any video calls and chatting to people? There are also a few virtual Clojure meetups happening. Is like to try attend sole of those myself


It might even be worth starting a small zoom group or something for people to have some #watercooler time with others struggling with the isolation

👍 4
Jakob Durstberger08:03:43

Yeah, I’ve been chatting with my family and colleagues and it makes it bearable. I am just a big fan of going into the office for work and being around other people

Jakob Durstberger08:03:35

We have similar things in place, we also have a 3pm tea time hangouts 🙂


Nice, that's really good to hear re the tea time hangouts 👍

Edward Hughes09:03:23

Sounds like a Clojure Discord server is on the cards 😀


I would love to be able to program, play VR and consume nothing but pizza and beer for a few weeks


Instead I'm having to run after a 2yo


Good luck with the two year old. At least you can't say you're getting bored... Probably just exhausted 😉



Rachel Westmacott09:03:30

things going... okay here. Luckily we have a garden to put the children in and the weather's been good so far. I imagine this is way harder for a lot of people than it is for me.

👍 8
Eamonn Sullivan09:03:06

It's only week two, but I'm still getting up at my normal hour, running my normal distance, showering, getting dressed in my normal clothes and then going to my "office" (the bedroom next to my own, where I've jury-rigged a stand-up desk with a laptop and external monitor). Let's see how long until I'm working in my bathrobe and slippers... My ears are getting sore from the constant usage of headphones for the videoconferences, though.

👍 4

Honestly i think this is the best plan, try and stick to your usual routine and adapt it a bit. Well done :thumbsup:


Yes, totally agree. I read/ watched something a while back about having a routine (getting out of bed, making the bed, getting dressed ect) was really healthy and helpful for people when they were unable to work etc. I think the same applies for everyone being stuck at home now. Keep a routine going to keep you going kind of thing


That might have been me banging on about having a well-defined WFH routine and delineating part of your living space as "the office" so you actually "commute" to your office and "commute" home when you're done working.


Having a separate work computer and a home computer also helps (I have a tiny laptop for home stuff and a 27" desktop dedicated to work stuff).


Unfortunately, this isn't feasible/practical for everyone 😞


Yeah, if memory serves me correctly, I think it was a TED talk I watched by someone that used to be in the military (possibly about how to deal with productively working from home), but my memory is a little hazy


Routine is definitely a good thing though. Otherwise the wheels can fall off 😂

Edward Hughes09:03:17

Morning folks.


I'm just curious how people that are getting food deliveries booked at all? > Number of users in queue ahead of you: 97524


I just shop


It's not too bad


Don't people feel, given this WFH increase that there seems to be more "control/checking" from up on top? After all, if you're not welded to your keyboard/video conference for at least 12 hours a day, you must be slacking(!) off in your yimyangs watching youtube videos of kitty cats.


Managers (I believe) don't like not seeing bums on seats...


Not with us; but we’re a pretty relaxed company — who’ve been doing remote working for years. If anything maybe we’ve gone more the other way… people starting to work more varied hours; and say things like “taking a few hours off to look after the kids” — but then making it up later, so probably overall an increase in flexibility. Though we always allowed that stuff anyway; more people require it now I think.

Ben Hammond10:03:13

being avalable on Slack/Email does not strongly correlate with being productiive

Ben Hammond10:03:35

Slack is just another outlet for procrastination

Ben Hammond10:03:44

/ create space for the subconscious to chew over your current problem as you care to describe it

Ben Hammond10:03:57

um I mean that progress is often invisible, especially if it is design-heavy

Ben Hammond10:03:27

the whole hammock-time/lotus shoots growing underneath the water thing


our company is not used to everyone working from home


so there is a bit more control going on

Ben Hammond11:03:16

from a middle-manager's point of view they are periously close to being shown up as unnecessary so haranguing you is their best way to seem relevant perhaps probably

Eamonn Sullivan11:03:38

Where I work, our team has been split between London and Glasgow for a long time. All meetings are remote-first, even if you were in the office, because no one likes to be the only remote person on the end of an intercom to a room full of people. So when we all had to go home, it wasn't that much of a difference. Where it hurts a bit is in pair programming. Every once in a while, you'd pair with someone in the same office and get a break from the headphones and screen sharing. Now we're on headphones all day, every day. But as far as management is concerned, they've gotten used to not seeing us and stuff still gets done. They're trained.

Ben Hammond11:03:06

Glasgow AND London? Is that Previse?

Eamonn Sullivan11:03:33

No, BBC. It's in my profile, I think.

Eamonn Sullivan11:03:24

Our particular team, which looks after all digital publishing, is primarily based in those two cities.


My thoughts are that we need to let them spy, for a while at least. Give them the initial comfort.


That's pretty much the end of my plan. Maybe "time".


The world seems overall better if society is remote first. Commuting, flying, is reduced. More time to rest, play with kids, etc.


Even if middle management want bums in seats. They'll ease off with time.


i'm confident you are just holding back because you've seen what happens to all those evil geniuses who spill the beans too early 😉

😂 4

I already used my quota of Austin Powers for the week, but you can guess :)


I'm stuck in OO thinking, i'm not sure I'm thinking this correctly in a FP way. I have api.clj wfich holds this function:

(defn ping-services
  "Pings all relevant external services and returns a status map"
  (log/debug "Pinging all external services")
  {:aggregator "DOWN"
   :baas "DOWN"
   :ml-service "DOWN"
   :database "DOWN"})
Now it hasn't been implemented yet, just returns a fixed map. In my head I'd create aggregator.clj, baas.clj, ml_service.clj and database.clj, each of them would have (amongst other things) a ping function which would know how to ping their service. Then for instance the value would be something like :database (database/ping) For some reason this does not feel right. I then started thinking about how I'd actually create tests for this (pins-services) function. In Java I'd just mock the Objects needed and inject them. I was told by one Clojurian that I could use a protocol and SPI Objects (?) for this instead, that is, pass in a function that does the http call (I could then have a function coming from database.clj that actually communicated with the database) and use a pass in a dummy function that returns "TRUE" in tests. But how would I do that? Or is this a good approach at all?


A million ways to do it — but agreggating the results into a map is the trivial bit. I’d suggest the main place is to test the individual ping procedures… If each of those returned {:service-id "VALUE"} aggregating them is just a merge. Or they can return [:id value] and can be put (into {} service-results)… either way I’d decouple along those kind of lines.


within each ping procedure, you can mock out http things or whatever


or you could call ping-services like (ping-services [ping-service-a ping-service-b]) where each service is just a fn/procedure to do the pinging; and ping-services just orchestrates and collects results. This can be tested with a arbitrary thunks, e.g.

(ping-services [(constantly [:service-a "DOWN"]) (constantly [:service-b "UP"])])


you can obviously bike shed the details — but would suggest something along those lines is a starting point


The important thing is to make this function be part of orchestration I think. Functions take it's result as a parameter, functions don't call it for you


@rickmoynihan @dominicm Good pointers, thanks a million. @dominicm Can you elaborate on that?


(report ping-data) not (report) where report: (defn report [] (ping))

👍 4

ah ok, so you mean passing in the report function, rather than letting ping-services take nothing and call the methods. Ofc that makes testing much easier


I meant the report data, not the function.


I think most of the time passing functions to domain logic is not idiomatic


Sorry I got pulled away before finishing everything — what @dominicm say’s is totally true btw. Though I was more imagining ping-services would orchestrate the execution of the procedures i.e. provide the strategy rather than report on them per se… At a basic level the distinction isn’t that important, but the orchestration is where the trickier aspects in this sort of thing happen; e.g. whether it’s acceptable for the requests themselves to be made sequentially; or whether they want to occur in parallel… then if parallel how you join the results back together; manage timeouts, different kinds of errors, retries whatever. Keeping those concerns separate from reporting then becomes important etc… it really depends on how far you want to go.

👍 8

The ping-services function is being called via http endpoint /health, so them taking some time does not matter really, it's really just something I might use to double check setup


So the function is not that important really


Hi isolated peeps! I'm in the market for a clj/cljs formatter - we have emacs, cursive and calva in the team, and calva can't format files with namespaced keywords because of a bug in cljfmt. Does anyone know of an IDE-independent formatter?


Zprint is your best bet


It's canonical unlike cljfmt, so there's no arguments


I hate the output though. It aims for 80 chars per line.


i do like 80 chars per line... lets me have 3 column layout in emacs


No. Max is fine. But zprint aims for lines to be 80 chars.


So you end up with long lets, things like that.


is the bug in cljfmt intractable?