Sure that’s a line of investigation is interesting. I was just wondering how hard it would be to simply do it in pure clojure. Allow people to pass in additional work to be done at each stage. It would be totally orthogonal to the existing API.
It’s kind of a crazy idea and it probably won’t work but maybe it could work.
pass some clojure code into macro that runs before the other stuff.
Does that make sense?
The Java SDK uses annotations because Java is such a weak language it can do what clojure can do.
I guess I’m not following what you mean by “pure clojure”. you mean rig up callbacks in your Clojure API, without using the Java annotations? obviously that would only work if users only ever used your Clojure API; it would not really be a datastore hook. since it’s basically trivial to register callbacks using deftype, why bother?
Because the code is ugly AF. And the annotations exist only because of the limitations of the Java language. Limitations that don't exist in Clojure.
But I probably I won't go that route anyway. It's a worthwhile thought experiment though.
@nickbauman check out https://github.com/technomancy/robert-hooke
@mobileink ohhh that’s actually quite beautiful!
You’re messing with my brain because now I really don’t want to use the annotations at all.
And before I saw that, I was planning to...
You’re a bad person 😉
Seriously, that’s cool.
you could prolly use that to hide the annotation cruft.
Sorry kinda slow in the brain.
I see that now
id be wary of trying to duplicate the gae callback mechanism in clj.
🤷 yeah
the result would inevitable be pretty fragile, methinks.
Hooks are meant to extend functions you don't control … more food for thought.
fragile for the post atuff, anyway. i could see using robert-hooke to intercept put ops. might be more efficient.
i suppose with robert-hooke we could hook any GAE method call. kinda cool.
@nickbauman you asked previously if my stuff supprts hooks. no. i havent worked on it for a while, i think they added the cb stuff after i got started, altho i would not swear to it. obviously sth that should be supported.
I’ve used hooks in the Python API extensively. I found it very useful.
(also easy to abuse, though)
being lazy, impatient, and hubristic, im inclined to just provide some sample code demonstrating use of deftype with method annotations.
Yeah it’s not wrong
To do that
regarding librarification: strong recommend. imho every gae service should be supported in a separate lib. if you do that then people can use the services with any build system. you should be able to use my datastore lib with your leinengen thingie, and i should be able to use your ds lib with my boot-gae thingie.
PCollection<KV<String, Integer>> scores = input
.apply(Window.into(FixedWindows.of(Duration.standardMinutes(2)))
.triggering(
AtWatermark()
.withEarlyFirings(AtPeriod(Duration.standardMinutes(1)))
.withLateFirings(AtCount(1)))
.accumulatingAndRetractingFiredPanes())
.apply(Sum.integersPerKey());
... There's gotta be a way to do this better, Google. And people complain about how Lisps use parentheses...@fellshard ok. whats the connection with google cloud?
i'd be happy to help, i just don't know what your question is.
Sorry, this was sample code from DataFlow articles. Pretty sure this is technically Apache Beam.
This seems like it's a suitable case for a data-driven DSL given it's intended to be purely declarative.