Fork me on GitHub
#untangled
<
2016-08-25
>
grzm12:08:34

@tony.kay taking a step back, this is consistent with where I eventually want to get: complete asynchrony between the mutations (commands) and the reads, not even returning the tempid mapping.

grzm12:08:12

-- at least not in the response to the mutation command.

therabidbanana15:08:22

We eventually got there too with our stuff. I think we just removed the widget/load-data-stream action in the example above and rely on push notifications via Sente now. Tempids are still useful there though - having a tempid that auto-resolves to a real id makes the push commands dead simple - we just listen on the channel for updates by id and swap those into place.

grzm15:08:28

@therabidbanana yeah, I still want to have tempids 🙂 Just not returning them on the initial mutate command. Like you describe, passing the tempid maps in a separate push once the real ids have been generated on the server/back end.

therabidbanana15:08:29

Ah, we haven't had to do anything like that yet - all our commands return quick enough we're fine with tempids coming back in the initial mutate command

therabidbanana15:08:17

In some scenarios we do assign a randomly generated uuid to a blob of data that takes a background job and 5-10 second wait to fetch, so that we can return that id immediately

grzm15:08:20

I'm thinking of a situation where you're writing the commands to an event queue (think Kafka), then consumers coming along and doing the actual work associated with the command.

grzm15:08:43

And one job of the consumers would be to figure out how to update the client.

therabidbanana15:08:25

I'd probably still go with a tempid resolving in that scenario - resolving implies that the event was successfully written to kafka.

grzm15:08:29

My app is nowhere near requiring that kind of system, but I have worked in environments like that, and I love the decoupling.

therabidbanana15:08:39

Then the real id is what's stored and communicated with via the command consumers. I'd handle it that way mainly because tempids are ephemeral and will disappear on refresh - maybe that's not a concern in your scenario though

grzm15:08:30

That's something to think about, too.

therabidbanana15:08:08

So our background job scenario is one of those kinds of cases - we use the uuid as the primary key for the data stream so we can communicate it back immediately

therabidbanana15:08:55

And we set a "status" on that entity with pending so we know it's not actually there yet

therabidbanana15:08:49

That lets us refresh in pending state, you pull from the db that the stream is still pending, and have an id to listen to for further push events.

grzm15:08:16

Interesting. What does your application/system do?

therabidbanana16:08:30

It's a cross-network advertising reporting dashboard (https://www.adstage.io/reporting/)

grzm16:08:26

Wow! Have you guys been happy with the stack?

therabidbanana16:08:12

So far, yes, very happy. There have been a few rough edges but overall it feels simpler to work with than what our other products have used (frontend Ember / backend Ruby on Rails).

therabidbanana16:08:14

We had the advantage of being able use our existing platform and pull reports from there, I'm not sure if I'd have been as happy to build out the integrations with 5 separate networks in clojure land - there's a few good ruby gems for working with those APIs

grzm16:08:33

I've historically been a backend/data guy. Nearly all of my front-end stuff has been nodejs/express. And while that's been really easy to get started with, I've found it's generally a mess going forward.

grzm16:08:10

I like how Om helps me thinking about the overall structure of the application

therabidbanana16:08:35

I generally lean more backend too - but with Om/Clojurescript I don't want to pull my hair out debugging javascript

therabidbanana16:08:44

So I consider that another plus

grzm16:08:37

Right. So your Ruby backend API handles Om-style reads and mutations?

therabidbanana16:08:39

Untangled's networking queue on top of that to force synchronous network requests where it makes sense (most of the time, generally), helps a lot with weird edge case type stuff we've seen in Ember too.

therabidbanana16:08:53

Our server for this product takes in the om reads/writes, and when we need a data blob from the Ruby platform, that's where we fetch the datastream in a background job

therabidbanana16:08:30

So you can build an entire report without talking to our Ruby app, it'll just all show with widgets in pending until those background jobs clear.

therabidbanana16:08:27

It let us iterate very quickly at the beginning, because we could just make a dumb worker that returned the same data every time

grzm16:08:03

Picking the right boundaries/interfaces is clutch.

therabidbanana16:08:14

Then we got it talking and just pointed it to our production app, since it's read-only

therabidbanana16:08:29

(As far as the Ruby API is concerned)

therabidbanana16:08:24

Agreed - having the right boundaries helps a lot.

grzm16:08:19

w00t! Just added a support viewer to my app 🙂

therabidbanana16:08:16

Nice! We got one set up a week or so ago - we're still waiting to catch our first session in the wild though. 😄

grzm16:08:44

I dunno ... Musa with rabies sounds pretty wild to me...

therabidbanana16:08:09

Heh - yes indeed - but I don't use our production app much. Also I was not aware of the term Musa until this moment.

grzm18:08:07

I looked it up 🙂

tony.kay19:08:15

@grzm You're biting off quite a bit of complexity there. I like the event stream model, too, but reasoning about tempids becomes really difficult if you don't at least do some kind of id step ASAP.

tony.kay19:08:36

It is most of the reason that Untangled does a sequential network queue for you.

tony.kay19:08:50

(and includes tempid remapping ON the network pending requests)

tony.kay19:08:25

Optimistically add an item. You have a tempid. Now the user can, at any time, delete it. Do you want the tempid going over the network as the id for that request?

tony.kay19:08:56

With Untangled/Om (and tempid reassign on return and sequential processing) the "right thing" happens.

tony.kay19:08:33

If you defer remapping, then you have to add extra logic on the server-side. Of course, that could be as simple as using the tempid as a permanent natural key...but that bloats your data a bit

tony.kay19:08:44

Also remember that with Untangled you get optimistic UI updates, so the user gets immediate feedback, even if your backend takes a while to produce the result. So nothing says you can't do your event stream model and just don't respond until the remap is ready...assuming you can get the response in less than the network timeouts (e.g. 30 seconds)

tony.kay19:08:10

I think there is room for expansion in Untangled's network stack as well. The sequential thing isn't always appropriate (e.g. blocking future reads because some sequence is pending inthe queue). The :parallel thing helps, but then you don't have sequencing on those reads (which is ok most of the time). Om supports multiple remotes (e.g. :remote true could instead be :remote :A). When we add support for multiple remotes, this could give you a way to use "alternate queues" based on which remote....and the remotes could technically all point to one specific remote (you just get multiple queues)

tony.kay19:08:24

lots of possibilities to explore 🙂

grzm19:08:25

You guys have been so awesome and generous today. Thank you 🙂

grzm19:08:03

The CQRS stuff I'm not looking at doing any time soon, but something I want to keep in mind as I consider different architectural decisions.

tony.kay19:08:32

welcome. The stack is new enough that some of these things are still being explored.

tony.kay19:08:05

Some have not been added because no one has yet shown the actual need, but that doesn't mean they are not needed for a fully general solution.

tony.kay19:08:16

supporting multiple remotes for queries (via a parameter to load-data) would also give these same benefits.

grzm19:08:40

I'll look into that, actually.

grzm19:08:49

Also for commands.

therabidbanana20:08:08

On the sequencing thing @tony.kay - what we've seen is that what we'd want :parallel true to do when we use it is go into the queue and when it comes up, then go unblocking.

therabidbanana20:08:25

If that makes any sense

therabidbanana20:08:02

Often we'd want to do a slow read on something after a mutation that creates that thing (like data streams), and we'd make that read parallel

tony.kay21:08:21

@therabidbanana Yeah, the "correct" behavior is supported by what we have, but it is obvious that (usually for optimization) there are other queue cases we should support.

tony.kay21:08:05

It's all in front of an easy abstraction, so it should be pretty easy to add whatever is needed. Just keeping the API clean and simple is the main concern.

therabidbanana21:08:28

Yeah, it's not really a problem for us now because we just used websockets instead, but I was at one point considering trying to add some sort of support for that into the networking layer