Brad Fitzpatrick (bradfitz) wrote in lj_dev,
Brad Fitzpatrick

ESN system

Update (2006-09-07): This post, while of historical interest, doesn't reflect the underlying implementation that finally happened in mid-2006. For actual data structures, see LJ/, LJ/, LJ/, etc...

This post is a quick introduction and overview of the forthcoming Event, Subscription, and Notification system, or ESN.

Basically, a ton of actions on the site will now fire events. An event type is technically 1 char for its type, 4 byte journal id, and 4 byte optional numeric argument. An actual event instance also has two other 4 byte fields, usually used for doer userid, and the new result id.

The API to fire an event is already in CVS, and talkpost_do.bml already uses it, though it does nothing yet, because....

Events only log to the database if somebody is subscribed to that event type. For each subscription, a user can choose their notification type. Initially only email and text message will be supported. Others in the future could be some web log of notifications or something.

Logging an event is O(1)[1] ... we log either 0 or 1 rows to the database, and this is done synchronously. Everything else is async: something will continually take an event off the front of the queue, find its subscribers, and send/pend notifications. (pend is future: for now we'll just send, but in the future we'll batch notification up such that they're not sent more than once every 5 minutes or something)

Types of notifications to be supported:
(J,journalid)+(ditemid) -- journal is updated (ditemid = which)
(R,journalid,ditemid)+(duserid,dtalkid) -- post is replied in
(T,journalid,dtalkid)+(duserid,dtalkid) -- thread is replied in
Other possible examples:
(P,journalid)+(picid) -- journalid has a new picture, and which
(B,journalid) -- new bio
(F,journalid)+(friendofid) -- friendofid added journalid as friend (only self and com. maintainers will be able to subscribe to this)

As far as paid/free ... paid users will be able to subscribe to anything. Free users will be able to subscribe to paid users' stuff, but with a cap on number of subscriptions.

What I need from somebody: the BML page to add/edit/delete your subscriptions. Anybody down?

[1] well, technically b-tree inserts aren't O(1), but you know what i mean... it's not O(subscribers). that's what's important.
Tags: esn
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

← Ctrl ← Alt
Ctrl → Alt →
← Ctrl ← Alt
Ctrl → Alt →