This was originally for macondo, but I may as well add it on here for tracking devlogs etc. In this first devlog I added User Authentication using my own custom Authentication Library within elixir called Amur. This handles all the callbacks and requests for OAuth2 providers, I piped what this returned to save within a postresql database and saved a cookie into the user browser. I was getting annoyed that when I visit the lander for on cloudflare for example, I would have to signin again. On this app I decided that if you have the cookie it attempts to signin. The cookie is encrypted and signed via phoenix. I then made a simple liveview dashboard written in elixir, the frontend uses tailwindcss and HEEX. This allows me to use hooks to use serverside rendering instead of javascript so it is a lot nicer. I then started making a UUID as a Service API. I could have made a uuid when the user requests one, but that is slow and inefficient, so I decided on bulk making UUIDv7s and inserting them into PG, when one is called, the “claimed” flag in the database turns from false into true, and my counter in my genserver decrements. If the counter gets below 250 UUIDs left I make another 1000. You might be thinking “What happens when two users request a UUID at the exact same time?”
I am using “SELECT FOR UPDATE SKIP LOCKED” in postgres so when two users request a record, the first user gets it and the second user skips that record instead of waiting to read it to see if it is claimed. This is a lot faster and better for concurrent systems like this one.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.