Hey folks, recently wrote up a few agents and genserver designed to handle recent site activity such as recent posts, upvotes, replies to your posts, pings from users and such. A nice fellow on reddit gave me a code review which got me a little deeper into OTP concepts so I did a rewrite that is definitely better than what I had. Still much to learn though so if anyone is interested I would love a design and code review of the new iteration.
Le codes: https://github.com/smileys-tavern/smileys_data/tree/master/lib/state
Here is what changed from my original design:
-
added supervisor for each style of bucket (buckets are agents or genservers depending on needs)
-
using simple one for one strategy
-
ditched some registries and added each bucket to a global registry maintained via syn (mnesia based) with a strategy of staying dead when crashed/killed. This is to keep imprint smaller since if there is any new activity a new bucket will be created
-
implemented a protocol that provides a uniform interface to all activity (I dont like it’s name so far, but its working well in terms of simplifying use for the client)
There’s a couple event expireys I’ve yet to implement in there and a couple of my own concerns but I’ll leave it at that for now. Happy to answer any questions about usage I missed