Skip to content

Instantly share code, notes, and snippets.

View philcleveland's full-sized avatar

Phil Cleveland philcleveland

View GitHub Profile
using System;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using EventStore.ClientAPI;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin.Hosting;
using Owin;
namespace EventStoreSignalR
@philcleveland
philcleveland / GetEventStoreEventDispatcher.cs
Last active June 8, 2016 23:04
Event dispatcher which receives events from the GetEventStore after they are saved. It takes the saved events and publishes them to the passed in Event Bus. This ensures that events are not published until they are saved in the GetEventStore. Big thanks to Andrii for all the reviews and coding help to get this thing working.
public class GetEventStoreEventDispatcher
{
private const int RECONNECT_TIMEOUT_MILLISEC = 5000;
private const int THREAD_KILL_TIMEOUT_MILLISEC = 5000;
private const int READ_PAGE_SIZE = 500;
private const int LIVE_QUEUE_SIZE_LIMIT = 10000;
private readonly IEventBus _eventBus;
private readonly EventStoreConnection _store;
public abstract class AggregateRoot : IAggregateRoot
{
private const int DefaultVersion = 0;
private readonly Dictionary<Type, Action<IEvent>> handlers = new Dictionary<Type, Action<IEvent>>();
private List<IEvent> _uncommitedChanges = new List<IEvent>();
public Guid Id { get; protected set; }
public int Version { get; private set; }