eparrot
02/24/2023, 12:53 AMGuillaumeLakano
02/24/2023, 6:03 PMHardAtWork
02/24/2023, 6:42 PMbrett
02/24/2023, 6:47 PMGuillaumeLakano
02/24/2023, 6:48 PMGuillaumeLakano
02/24/2023, 6:48 PMbrett
02/24/2023, 6:49 PMGuillaumeLakano
02/24/2023, 6:50 PMGuillaumeLakano
02/24/2023, 7:05 PMbrett
02/24/2023, 7:06 PM{locationHint: 'enam'}
and then it would be a random colo in ENAMGuillaumeLakano
02/24/2023, 7:07 PMbrett
02/24/2023, 7:07 PMidFromName(primaryKeyFromYourSQLDB)
or somethingbrett
02/24/2023, 7:07 PMGuillaumeLakano
02/24/2023, 7:08 PMGuillaumeLakano
02/24/2023, 7:08 PMbrett
02/24/2023, 7:09 PMbrett
02/24/2023, 7:09 PMGuillaumeLakano
02/24/2023, 7:10 PMzehawk
02/25/2023, 2:04 PMWallslide
02/25/2023, 6:34 PMput
and delete
functions support up to 128 keys at a time. But what if I loop over them without using await over 128 times (taking advantage of automatic write coalescing). Is that going to run into the same limit?Wallslide
02/25/2023, 6:36 PMLarry
02/26/2023, 8:32 PMDani Foldi
02/26/2023, 9:00 PMdo-transactional-outbox
for an even stronger model of storage consistency. For your example in the blog post, I'm not sure if by using await
you potentially eliminate (some of) the benefits of caching state in memory, let me explain.
I recommend taking a look at `state.blockConcurrencyWhile`: call it in your constructor, no need to await it (you couldn't anyways, since constructors have to be sync), but it blocks further requests until you finish with your hydrate
function.
Then, you can always be sure that this.name
and others will have been populated whenever your request comes in via fetch
, so you can simplify your code further - eliminating another potential concurrency issue, where you're awaiting the hydrate promise, and another event handler starts executing, calling hydrate again, and potentially reading from storage once more as this.hydrated may not have been set to true yet (knock knock, race condition, who's there type situation), and then you overwrite name from the second call.
Basically, use blockConcurrencyWhile
in the constructor, move hydrate
to within that call and remove it from fetch
. Oh, small note, you could reduce boilerplate by exporting a function instead of a class, which applies the argument as the static class and returns that as the DO class for the runtime DanTheGoodman
02/26/2023, 9:59 PMctx.waitUntil
with durable objects? I don't see any way to get the execution context from the fetch handler in a DO (it's undefined) (plz ping)Skye
02/26/2023, 10:13 PMDanTheGoodman
02/26/2023, 10:13 PMSkye
02/26/2023, 10:13 PMDanTheGoodman
02/26/2023, 10:14 PMSkye
02/26/2023, 10:14 PMSkye
02/26/2023, 10:14 PM