public void SetUp() { _resolverMock = InjectMock <IServiceProvider>(); _snapshotDefinitionService = Inject <ISnapshotDefinitionService>(new SnapshotDefinitionService( Mock <ILogger <SnapshotDefinitionService> >(), Mock <ILoadedVersionedTypes>())); }
protected AggregateSaga() { Settings = new AggregateSagaSettings(Context.System.Settings.Config); var idValue = Context.Self.Path.Name; PersistenceId = idValue; Id = (TIdentity)Activator.CreateInstance(typeof(TIdentity), idValue); if (Id == null) { throw new InvalidOperationException( $"Identity for Saga '{Id.GetType().PrettyPrint()}' could not be activated."); } if ((this as TAggregateSaga) == null) { throw new InvalidOperationException( $"AggregateSaga {Name} specifies Type={typeof(TAggregateSaga).PrettyPrint()} as generic argument, it should be its own type."); } if (State == null) { try { State = (TSagaState)Activator.CreateInstance(typeof(TSagaState)); } catch (Exception exception) { Context.GetLogger().Error(exception, "AggregateSaga of Name={1}; was unable to activate SagaState of Type={0}.", Name, typeof(TSagaState).PrettyPrint()); } } if (Settings.AutoReceive) { InitReceives(); InitAsyncReceives(); } InitTimeoutJobManagers(); InitAsyncTimeoutJobManagers(); if (Settings.UseDefaultEventRecover) { Recover <ICommittedEvent <TAggregateSaga, TIdentity, IAggregateEvent <TAggregateSaga, TIdentity> > >(Recover); Recover <RecoveryCompleted>(Recover); } if (Settings.UseDefaultSnapshotRecover) { Recover <SnapshotOffer>(Recover); } Command <SaveSnapshotSuccess>(SnapshotStatus); Command <SaveSnapshotFailure>(SnapshotStatus); _eventDefinitionService = new EventDefinitionService(Context.GetLogger()); _snapshotDefinitionService = new SnapshotDefinitionService(Context.GetLogger()); }
protected AggregateSaga() { Logger = Context.GetLogger(); Settings = new AggregateSagaSettings(Context.System.Settings.Config); var idValue = Context.Self.Path.Name; PersistenceId = idValue; Id = (TIdentity)Activator.CreateInstance(typeof(TIdentity), idValue); if (Id == null) { throw new InvalidOperationException( $"Identity for Saga '{Id.GetType().PrettyPrint()}' could not be activated."); } if ((this as TAggregateSaga) == null) { throw new InvalidOperationException( $"AggregateSaga '{GetType().PrettyPrint()}' specifies '{typeof(TAggregateSaga).PrettyPrint()}' as generic argument, it should be its own type"); } if (State == null) { try { State = (TSagaState)Activator.CreateInstance(typeof(TSagaState)); } catch { Logger.Warning($"Unable to activate State for {GetType()}"); } } if (Settings.AutoReceive) { InitReceives(); InitAsyncReceives(); } Register(State); if (Settings.UseDefaultEventRecover) { Recover <ICommittedEvent <TAggregateSaga, TIdentity, IAggregateEvent <TAggregateSaga, TIdentity> > >(Recover); Recover <RecoveryCompleted>(Recover); } if (Settings.UseDefaultSnapshotRecover) { Recover <SnapshotOffer>(Recover); } _eventDefinitionService = new EventDefinitionService(Logger); _snapshotDefinitionService = new SnapshotDefinitionService(Logger); }
public SnapshotSerilizer( ILog log, IJsonSerializer jsonSerializer, ISnapshotUpgradeService snapshotUpgradeService, ISnapshotDefinitionService snapshotDefinitionService) { _log = log; _jsonSerializer = jsonSerializer; _snapshotUpgradeService = snapshotUpgradeService; _snapshotDefinitionService = snapshotDefinitionService; }
protected AggregateRoot(TIdentity id) { Settings = new AggregateRootSettings(Context.System.Settings.Config); if (id == null) { throw new ArgumentNullException(nameof(id)); } if ((this as TAggregate) == null) { throw new InvalidOperationException( $"Aggregate {Name} specifies Type={typeof(TAggregate).PrettyPrint()} as generic argument, it should be its own type."); } if (State == null) { try { State = (TAggregateState)Activator.CreateInstance(typeof(TAggregateState)); } catch (Exception exception) { Context.GetLogger().Error(exception, "Unable to activate AggregateState of Type={0} for AggregateRoot of Name={1}.", typeof(TAggregateState).PrettyPrint(), Name); } } PinnedCommand = null; _eventDefinitionService = new EventDefinitionService(Context.GetLogger()); _snapshotDefinitionService = new SnapshotDefinitionService(Context.GetLogger()); Id = id; PersistenceId = id.Value; SetSourceIdHistory(100); if (Settings.UseDefaultSnapshotRecover) { Recover <SnapshotOffer>(Recover); } Command <SaveSnapshotSuccess>(SnapshotStatus); Command <SaveSnapshotFailure>(SnapshotStatus); if (Settings.UseDefaultEventRecover) { Recover <ICommittedEvent <TAggregate, TIdentity, IAggregateEvent <TAggregate, TIdentity> > >(Recover); Recover <RecoveryCompleted>(Recover); } InitReceives(); SetReceiveTimeout(Settings.SetReceiveTimeout); Command <ReceiveTimeout>(Timeout); }
public DefinitionServicesInitilizer( ILoadedVersionedTypes loadedVersionedTypes, IEventDefinitionService eventDefinitionService, ICommandDefinitionService commandDefinitionService, IJobDefinitionService jobDefinitionService, ISagaDefinitionService sagaDefinitionService, ISnapshotDefinitionService snapshotDefinitionService) { _loadedVersionedTypes = loadedVersionedTypes; _eventDefinitionService = eventDefinitionService; _commandDefinitionService = commandDefinitionService; _jobDefinitionService = jobDefinitionService; _sagaDefinitionService = sagaDefinitionService; _snapshotDefinitionService = snapshotDefinitionService; }
protected AggregateRoot(TIdentity id) { Logger = Context.GetLogger(); Settings = new AggregateRootSettings(Context.System.Settings.Config); if (id == null) { throw new ArgumentNullException(nameof(id)); } if ((this as TAggregate) == null) { throw new InvalidOperationException( $"Aggregate '{GetType().PrettyPrint()}' specifies '{typeof(TAggregate).PrettyPrint()}' as generic argument, it should be its own type"); } if (State == null) { try { State = (TAggregateState)Activator.CreateInstance(typeof(TAggregateState)); } catch { Logger.Error($"Unable to activate State for {GetType()}"); } } _eventDefinitionService = new EventDefinitionService(Logger); _snapshotDefinitionService = new SnapshotDefinitionService(Logger); Id = id; PersistenceId = id.Value; Register(State); if (Settings.UseDefaultSnapshotRecover) { Recover <SnapshotOffer>(Recover); } Command <SaveSnapshotSuccess>(SnapshotStatus); Command <SaveSnapshotFailure>(SnapshotStatus); if (Settings.UseDefaultEventRecover) { Recover <ICommittedEvent <TAggregate, TIdentity, IAggregateEvent <TAggregate, TIdentity> > >(Recover); Recover <RecoveryCompleted>(Recover); } }
public void SetUp() { _resolverMock = InjectMock <IResolver>(); _snapshotDefinitionService = Inject <ISnapshotDefinitionService>(new SnapshotDefinitionService(A <ILog>())); }