Hacker News new | past | comments | ask | show | jobs | submit login

This is pretty cool.

I in particular like the output gates, I really like that way of handling transaction durability, where you do all the work, but external side-effects are only triggered when the transaction successfully commits. That, combined with the caching makes it really powerful.

There is a case for input gates, I didn't completely follow at first, and I think it might be worth adding as an example to the article. What happens if I do:

  promise = this.storage.get("counter")
  promise2 = fetch("blah")
  await promise2
  await promise
At first I thought this would deadlock, until I looked into the proper description for the input gates:

Any other events will be deferred until such a time as the object is no longer executing JavaScript code and is no longer waiting for any storage operations.

In particular, the "until such a time as the object is no longer executing JavaScript code" - in that case, we would not be running any code, and just return the result of the fetch. If you have two requests doing this, then you may end up with races again. It's akin to your later example with two concurrent storage operations, but in this case there is only one read.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: