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
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Erwin
Erwinβ€’2y ago
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
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
aarhus
aarhusβ€’2y ago
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
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
aarhus
aarhusβ€’2y ago
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
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
aarhus
aarhusβ€’2y ago
Agreed πŸ™‚
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
aarhus
aarhusβ€’2y ago
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
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
aarhus
aarhusβ€’2y ago
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
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
aarhus
aarhusβ€’2y ago
whoop! Now just to solve your backup concern....
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
aarhus
aarhusβ€’2y ago
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
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
aarhus
aarhusβ€’2y ago
That's a shame, but I supposed it is expected πŸ‘