Esempio n. 1
0
        public static Task publishToReadModel(ResolvedEvent eS_Event)
        {
            EventFromES normal = NormalizeESEvent(eS_Event);

            EventDistributor.Publish(normal);
            return(Task.FromResult(0));
        }
Esempio n. 2
0
        public static List <EventFromES> HydrateFromES(string streamId)
        {
            var eventStream = connection.ReadStreamEventsForwardAsync(streamId, 0, 256, false).Result.Events;
            List <EventFromES> theWetList = new List <EventFromES>();

            foreach (var eS_Event in eventStream)
            {
                EventFromES normalized = NormalizeESEvent(eS_Event);
                theWetList.Add(normalized);
            }
            return(theWetList);
        }
Esempio n. 3
0
 public static void Queue(EventFromES theEvent)
 {
     publishingQueue.Add(theEvent);
     while (publishingQueue.Count > 0)
     {
         EventDistributor.Publish(publishingQueue[0]);
         if (publishingQueue.Count > 0)
         {
             publishingQueue.RemoveAt(0);
         }
     }
 }
Esempio n. 4
0
        private static EventFromES NormalizeESEvent(ResolvedEvent eS_Event)
        {
            string      eventData = System.Text.Encoding.UTF8.GetString(eS_Event.Event.Data);
            dynamic     body      = JsonConvert.DeserializeObject <dynamic>(eventData);
            EventFromES fromES    = new EventFromES
            {
                StreamId  = eS_Event.OriginalStreamId,
                Id        = eS_Event.OriginalStreamId,
                Data      = body,
                EventType = eS_Event.Event.EventType,
                TimeStamp = eS_Event.Event.Created.ToString()
            };

            return(fromES);
        }