コード例 #1
0
        public async Task FireEventK8sNamespaceCreatedAndAwsArnConnected(string namespaceName, Guid contextId, Guid capabilityId)
        {
            try
            {
                var evtPre = new K8sNamespaceCreatedAndAwsArnConnectedEvent(namespaceName, contextId, capabilityId);

                var evt = new DomainEventEnvelope
                {
                    EventId = Guid.NewGuid(),
                    Created = DateTime.UtcNow,
                    Type    = _domainEventRegistry.GetTypeNameFor(evtPre),
                    Format  = "application/json",
                    Data    = JsonConvert.SerializeObject(evtPre, new JsonSerializerSettings
                    {
                        ContractResolver = new CamelCasePropertyNamesContractResolver()
                    })
                };

                // TODO JFHEI : Need to make this async
                _publishingEventsQueue.AddEventToQueue(evt);
            }
            catch (Exception ex)
            {
                Log.Error($"An error occured trying to emit an event from K8sApplicationService: {ex.Message}");
            }
        }
コード例 #2
0
ファイル: Outbox.cs プロジェクト: lulzzz/capability-service
        public Task QueueDomainEvents(IAggregateDomainEvents aggregate)
        {
            var domainEvents = aggregate
                               .DomainEvents
                               .Select(@event => new DomainEventEnvelope
            {
                EventId     = Guid.NewGuid(),
                AggregateId = aggregate.GetAggregateId(),
                Created     = DateTime.UtcNow,
                Type        = _eventRegistry.GetTypeNameFor(@event),
                Format      = "application/json",
                Data        = JsonConvert.SerializeObject(@event, new JsonSerializerSettings
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                })
            })
                               .ToArray();

            return(QueueDomainEvents(domainEvents));
        }