public V2DynamoDbSagaRepository(IDynamoDBContext connection, DynamoDbEventStoreOptions options, KnownEventTypes knownTypes) { _connection = connection ?? throw new ArgumentNullException(nameof(connection)); _options = options ?? throw new ArgumentNullException(nameof(options)); _knownTypes = knownTypes ?? throw new ArgumentNullException(nameof(knownTypes)); if (TypeMapping.GetTypeName(typeof(V2EventSourcedSagaInstance.SagaInstanceTransitioned)).Contains("+")) { TypeMapping.Add <V2EventSourcedSagaInstance.SagaInstanceTransitioned>("SagaInstanceTransitioned"); } }
public StateMachineSpecs(DynamoDbEventStoreFixture fixture) { _knownEventTypes = new KnownEventTypes(); _knownEventTypes.RegisterTypes(typeof(ProcessStarted), typeof(ProcessStopped), typeof(SomeStringAssigned)); _fixture = fixture; _sagaId = Guid.NewGuid(); _harness = new InMemoryTestHarness(); _repository = new DynamoDbSagaRepository <Instance>(_fixture.Connection, _fixture.Options, _knownEventTypes); _machine = new TestStateMachine(); _saga = _harness.StateMachineSaga(_machine, _repository); TaskUtil.Await(StartHarness); }
public bool TryGetSubscribers(KnownEventTypes eventType, out List <uint> subscribers) { subscribers = new List <uint>(); if (eventType != KnownEventTypes.Any && this.subscribersByEventType.TryGetValue(KnownEventTypes.Any.ToEventTypeString(), out var anySubscribers)) { subscribers.AddRange(anySubscribers); } if (this.subscribersByEventType.TryGetValue(eventType.ToEventTypeString(), out var typeSubscribers)) { subscribers.AddRange(typeSubscribers); } return(subscribers.Count > 0); }
public DynamoDbSagaRepository(IDynamoDBContext connection, DynamoDbEventStoreOptions options, KnownEventTypes knownTypes) { _connection = connection ?? throw new ArgumentNullException(nameof(connection)); _knownTypes = knownTypes ?? throw new ArgumentNullException(nameof(knownTypes)); if (options == null) { throw new ArgumentNullException(nameof(options)); } _configuration = new DynamoDBOperationConfig { OverrideTableName = options.StoreName, Conversion = DynamoDBEntryConversion.V2 }; if (TypeMapping.GetTypeName(typeof(EventSourcedSagaInstance.SagaInstanceTransitioned)).Contains("+")) { TypeMapping.Add <EventSourcedSagaInstance.SagaInstanceTransitioned>("SagaInstanceTransitioned"); } }
public async Task <bool> RaiseEventAsync(KnownEventTypes eventType, JRaw eventResultObject) { var context = this.activeRequestContext; if (context.EventSubscriptionsProcessor.TryGetSubscribers(eventType, out var subscribers)) { foreach (var id in subscribers) { await context.SendMessageAsync(new EventResultMessage() { Event = eventResultObject, Id = id }, default); } return(true); } return(false); }
/// <summary> /// Converts a given <see cref="KnownEventTypes"/> to a snake case <see cref="string"/>. /// </summary> /// <param name="eventType">A <see cref="KnownEventTypes"/>.</param> /// <returns> /// The service as a <see cref="string"/>. /// </returns> public static string ToEventTypeString(this KnownEventTypes eventType) { return(knownEventTypesCache.AsString(eventType)); }