As we mentioned in a recent post, we are going to be using
BrightstarDB to create ready-to-go data models that can be used by developers in building their applications. First up is a data model that captures events, subscribers and topics to provide a core data model for any event registration and timeline system. All the code is available for use in the BrightstarDB github repository.
One requirement we often see for intranet based projects is the notion of an event stream that is personalized for each user. The concept is quite simple, subscribers subscribe to topics. Events occur at a given time and these events are classified by one or more topics. Events can come from many systems, (we don’t go into detail about how these events are captured). A subscriber timeline is a list of all events that are classified by the same topic(s) that a subscriber is interested in. More specifically, the subscriber will only see events that occurred when they were interested in a given topic. Finally, events have associated data. This data can be different for each event. By using
BrightstarDB, we can combine a typed model for (
Topic) and also use dynamic features to capture the event data.
BrightstarDB was a good choice for this model as it allowed us to quickly iterate and try out new model ideas, and make use of the schema-less features of the underlying triple store.
We have defined a
EventFeed service object that provides high level access to the functionality. It has the following operations:
public interface IEventFeedService
void AssertSubscriber(string userName, IEnumerable<Uri> topicsOfInterest);
IEnumerable<IEvent> GetSubscriberTimeline(string userName, DateTime since);
IEnumerable<IEvent> GetTopicTimeline(string topicId, DateTime since);
void AssertTopic(Uri topicId, string label, string description);
dynamic GetEventData(IEvent feedEvent);
void RaiseEvent(string description, DateTime when, IEnumerable<string> topicIds,
Dictionary<string, object> eventProperties = null);
void RegisterInterest(string userName, string topicId);
void RemoveInterest(string userName, string topicId);
The data model consists of just three types:
ISubscriber, and is shown in the diagram below:
We hope this model is useful to someone, either as is, or as a starting point for something bigger and better. Also, if you are looking at how dynamic and typed objects can live together, then check out the service method for
All feedback welcome to contact(at)brightstardb.com, or @brightstardb.