ulid-workers
How about using a ULID? https://www.npmjs.com/package/ulid-workers
npm
ulid-workers
ULID generator for Cloudflare workers. Latest version: 2.0.0, last published: 9 months ago. Start using ulid-workers in your project by running
npm i ulid-workers
. There are 2 other projects in the npm registry using ulid-workers.18 Replies
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
I thought about this case for a while, but the chance of a migration happening in the max skew time between 2 machines in the same database clusters canβt be more than 0 in practice..
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
Without CF exposing an "instance id" (can't think of a better term - but something that uniquely refers to datacentre/host/do) this would also be very difficult to detect as well. What is the level of risk you are trying to mitigate?
I think the best thing would be to create the ulid (or whatever you choose) in the worker and then pass it to the DO.
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
Ah, got it.
So, if Erwin says that the time is effectively zero, why not put a long running (a second?) in the constructor with a blockConcurrencyWhile around it?
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
Agreed π
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
I like that! You could then also monitor for failures of this (i.e. log it) so you have some supporting data if you ever need to prove the consistency
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
But you could use a prefix of the current time......
actually startAfter
then it will only return something in the edge case you are trying to prevent π
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
whoop!
Now just to solve your backup concern....
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
No problem. I like chatting through problems like this. Whenever I am stuck I try and explain the problem to a non techy and nearly always get a solution by being forced to break it down into something they can understand. My mum is now an expert in remote API caching and durable object key spiltting!
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
That's a shame, but I supposed it is expected
π