Exemple #1
0
        public async Task <EventLocation> GetConsumingServices()
        {
            var eventLocation = await _statusRepository.GetEventLocation();

            return(new EventLocation(
                       eventLocation.Services,
                       eventLocation.UnresolvedEventSubscriptions,
                       eventLocation.UnresolvedReadModeSubscriptions));
        }
Exemple #2
0
        public async Task <HttpClient> GetClient <T>()
        {
            var eventLocation = await _statusRepository.GetEventLocation();

            var type = typeof(T);

            if (type.GetGenericTypeDefinition() == typeof(AsyncEventHandler <,>) ||
                type.GetGenericTypeDefinition() == typeof(QueryEventHandler <,>))
            {
                var eventType           = type.GetGenericArguments().Last();
                var domainEventLocation = eventLocation.GetServiceForEvent(eventType);
                if (domainEventLocation == null)
                {
                    return(DefaultHttpClient());
                }
                var httpClient = await _httpClientFactory.CreateHttpClient(domainEventLocation.ServiceEndPoint.ServiceBaseAddress);

                httpClient.BaseAddress = new Uri(domainEventLocation.ServiceEndPoint.ServiceBaseAddress + $"Api/DomainEventTypeStreams/{eventType.Name}");
                return(httpClient);
            }
            else
            {
                var readModelType = type.GetGenericArguments().First();
                var subscriberEventAndReadmodelConfig = eventLocation.GetServiceForReadModel(readModelType);
                if (subscriberEventAndReadmodelConfig == null)
                {
                    return(DefaultHttpClient());
                }
                var httpClient = await _httpClientFactory.CreateHttpClient(subscriberEventAndReadmodelConfig.ServiceEndPoint.ServiceBaseAddress);

                httpClient.BaseAddress = new Uri(subscriberEventAndReadmodelConfig.ServiceEndPoint.ServiceBaseAddress + "Api/DomainEvents");
                return(httpClient);
            }
        }