/// <summary> /// Initializes a new instance of the <see cref="ProjectionsService"/> class. /// </summary> /// <param name="executionContextCreator">The execution context creator to use to validate execution contexts.</param> /// <param name="getProjectionStoreFor">The factory to use to create projection stores per tenant.</param> public ProjectionsService( ICreateExecutionContexts executionContextCreator, Func <TenantId, IProjectionStore> getProjectionStoreFor) { _executionContextCreator = executionContextCreator; _getProjectionStoreFor = getProjectionStoreFor; }
/// <summary> /// Initializes a new instance of the <see cref="EmbeddingsService"/> class. /// </summary> /// <param name="executionContextCreator">The execution context creator to use to validate execution contexts.</param> /// <param name="getEmbeddingStoreFor">The factory to use to create embedding stores per tenant.</param> public EmbeddingsService( ICreateExecutionContexts executionContextCreator, Func <TenantId, IEmbeddingStore> getEmbeddingStoreFor) { _executionContextCreator = executionContextCreator; _getEmbeddingStoreFor = getEmbeddingStoreFor; }
/// <summary> /// Initializes a new instance of the <see cref="FiltersService"/> class. /// </summary> /// <param name="hostApplicationLifetime">The <see cref="IHostApplicationLifetime" />.</param> /// <param name="streamProcessors">The <see cref="IStreamProcessors" />.</param> /// <param name="filterForAllTenants">The <see cref="IValidateFilterForAllTenants" />.</param> /// <param name="executionContextCreator">The <see cref="ICreateExecutionContexts" />.</param> /// <param name="streamDefinitions">The <see cref="IFilterDefinitions" />.</param> /// <param name="reverseCallServices">The <see cref="IInitiateReverseCallServices" />.</param> /// <param name="unpartitionedFiltersProtocol">The <see cref="IUnpartitionedFiltersProtocol" />.</param> /// <param name="partitionedFiltersProtocol">The <see cref="IPartitionedFiltersProtocol" />.</param> /// <param name="publicFiltersProtocol">The <see cref="IPublicFiltersProtocol" />.</param> /// <param name="createUnpartitionedFilterProcessorFor">The factory to use to create unpartitioned filter processors.</param> /// <param name="createPartitionedFilterProcessorFor">The factory to use to create partitioned filter processors.</param> /// <param name="createPublicFilterProcessorFor">The factory to use to create public filter processors.</param> /// <param name="logger">The logger to use for logging.</param> public FiltersService( IHostApplicationLifetime hostApplicationLifetime, IStreamProcessors streamProcessors, IValidateFilterForAllTenants filterForAllTenants, ICreateExecutionContexts executionContextCreator, IStreamDefinitions streamDefinitions, IInitiateReverseCallServices reverseCallServices, IUnpartitionedFiltersProtocol unpartitionedFiltersProtocol, IPartitionedFiltersProtocol partitionedFiltersProtocol, IPublicFiltersProtocol publicFiltersProtocol, Func <TenantId, ScopeId, FilterDefinition, UnpartitionedFilterDispatcher, Unpartitioned.FilterProcessor> createUnpartitionedFilterProcessorFor, Func <TenantId, ScopeId, FilterDefinition, PartitionedFilterDispatcher, Partitioned.FilterProcessor> createPartitionedFilterProcessorFor, Func <TenantId, PublicFilterDefinition, PublicFilterDispatcher, PublicFilterProcessor> createPublicFilterProcessorFor, ILogger logger) { _hostApplicationLifetime = hostApplicationLifetime; _streamProcessors = streamProcessors; _filterForAllTenants = filterForAllTenants; _executionContextCreator = executionContextCreator; _streamDefinitions = streamDefinitions; _reverseCallServices = reverseCallServices; _unpartitionedFiltersProtocol = unpartitionedFiltersProtocol; _partitionedFiltersProtocol = partitionedFiltersProtocol; _publicFiltersProtocol = publicFiltersProtocol; _createUnpartitionedFilterProcessorFor = createUnpartitionedFilterProcessorFor; _createPartitionedFilterProcessorFor = createPartitionedFilterProcessorFor; _createPublicFilterProcessorFor = createPublicFilterProcessorFor; _logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="SubscriptionsService"/> class. /// </summary> /// <param name="executionContextCreator">The execution context creator to use for verifying incoming execution contexts.</param> /// <param name="getSubscriptionsFor">The factory to use to create an <see cref="ISubscriptions"/> for a tenant.</param> /// <param name="metrics">The system for capturing metrics.</param> /// <param name="logger">The logger to use for logging.</param> public SubscriptionsService( ICreateExecutionContexts executionContextCreator, Func <TenantId, ISubscriptions> getSubscriptionsFor, IMetricsCollector metrics, ILogger logger) { _executionContextCreator = executionContextCreator; _getSubscriptionsFor = getSubscriptionsFor; _metrics = metrics; _logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="ReverseCallDispatchers"/> class. /// </summary> /// <param name="requestIdentifier">The <see cref="IIdentifyRequests"/> for identifying requests.</param> /// <param name="executionContextCreator">The <see cref="ICreateExecutionContexts"/> to use.</param> /// <param name="metricsCollector">The <see cref="IMetricsCollector"/>.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> to use for creating instances of <see cref="ILogger"/>.</param> /// <param name="pingedConnectionFactory">The <see cref="IKeepConnectionsAlive"/> for creating pinged connections.</param> public ReverseCallDispatchers( IIdentifyRequests requestIdentifier, ICreateExecutionContexts executionContextCreator, IMetricsCollector metricsCollector, ILoggerFactory loggerFactory, IKeepConnectionsAlive pingedConnectionFactory) { _requestIdentifier = requestIdentifier; _executionContextCreator = executionContextCreator; _metricsCollector = metricsCollector; _loggerFactory = loggerFactory; _pingedConnectionFactory = pingedConnectionFactory; }
/// <summary> /// Initializes a new instance of the <see cref="ProjectionsService"/> class. /// </summary> /// <param name="reverseCallServices">The initiator to use to start reverse call protocols.</param> /// <param name="protocol">The projections protocol to use to parse and create messages.</param> /// <param name="executionContextCreator">The execution context creator to use to validate execution contexts on requests.</param> /// <param name="projections">The <see cref="IProjections"/> to use to register projections.</param> /// <param name="hostApplicationLifetime">The <see cref="IHostApplicationLifetime"/> to use to stop ongoing reverse calls when the application is shutting down.</param> /// <param name="logger">The logger to use for logging.</param> public ProjectionsService( IInitiateReverseCallServices reverseCallServices, IProjectionsProtocol protocol, ICreateExecutionContexts executionContextCreator, IProjections projections, IHostApplicationLifetime hostApplicationLifetime, ILogger logger) { _reverseCallServices = reverseCallServices; _protocol = protocol; _executionContextCreator = executionContextCreator; _projections = projections; _hostApplicationLifetime = hostApplicationLifetime; _logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="EventHorizon"/> class. /// </summary> /// <param name="id">The <see cref="EventHorizonId"/>.</param> /// <param name="consent">The <see cref="ConsentId"/>.</param> /// <param name="currentPosition">The initial current <see cref="StreamPosition"/> of the event horizon.</param> /// <param name="dispatcher">The reverse call dispatcher.</param> /// <param name="executionContexts">The <see cref="ICreateExecutionContexts"/>.</param> /// <param name="getEventFetchers">The <see cref="Func{TResult}"/> callback for getting <see cref="IEventFetchers"/> in a tenant container.</param> /// <param name="getStreamWaiter">The <see cref="Func{TResult}"/> callback for getting <see cref="IStreamEventWatcher"/> in a tenant container</param> /// <param name="metrics">The <see cref="IMetricsCollector"/>.</param> /// <param name="logger">The <see cref="ILogger"/>.</param> /// <param name="cancellationToken">The cancellation token.</param> public EventHorizon( EventHorizonId id, ConsentId consent, StreamPosition currentPosition, IReverseCallDispatcher <EventHorizonConsumerToProducerMessage, EventHorizonProducerToConsumerMessage, ConsumerSubscriptionRequest, SubscriptionResponse, ConsumerRequest, ConsumerResponse> dispatcher, ICreateExecutionContexts executionContexts, Func <TenantId, IEventFetchers> getEventFetchers, Func <TenantId, IStreamEventWatcher> getStreamWaiter, IMetricsCollector metrics, ILogger logger, CancellationToken cancellationToken) { Consent = consent; _dispatcher = dispatcher; _executionContexts = executionContexts; _getEventFetchers = getEventFetchers; _getStreamWaiter = getStreamWaiter; _metrics = metrics; _logger = logger; Id = id; CurrentPosition = currentPosition; _cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); }
/// <summary> /// Initializes an instance of the <see cref="EmbeddingsService" /> class. /// </summary> /// <param name="hostApplicationLifetime"></param> /// <param name="executionContextCreator"></param> /// <param name="reverseCallServices"></param> /// <param name="protocol"></param> /// <param name="getEmbeddingProcessorFactoryFor"></param> /// <param name="embeddingProcessors"></param> /// <param name="embeddingRequestFactory"></param> /// <param name="embeddingDefinitionComparer"></param> /// <param name="embeddingDefinitionPersister"></param> /// <param name="logger"></param> public EmbeddingsService( IHostApplicationLifetime hostApplicationLifetime, ICreateExecutionContexts executionContextCreator, IInitiateReverseCallServices reverseCallServices, IEmbeddingsProtocol protocol, Func <TenantId, IEmbeddingProcessorFactory> getEmbeddingProcessorFactoryFor, IEmbeddingProcessors embeddingProcessors, ICompareEmbeddingDefinitionsForAllTenants embeddingDefinitionComparer, IPersistEmbeddingDefinitionForAllTenants embeddingDefinitionPersister, IEmbeddingRequestFactory embeddingRequestFactory, ILoggerFactory loggerFactory) { _hostApplicationLifetime = hostApplicationLifetime; _executionContextCreator = executionContextCreator; _reverseCallServices = reverseCallServices; _protocol = protocol; _getEmbeddingProcessorFactoryFor = getEmbeddingProcessorFactoryFor; _embeddingProcessors = embeddingProcessors; _embeddingDefinitionComparer = embeddingDefinitionComparer; _embeddingDefinitionPersister = embeddingDefinitionPersister; _embeddingRequestFactory = embeddingRequestFactory; _loggerFactory = loggerFactory; _logger = loggerFactory.CreateLogger <EmbeddingsService>(); }
/// <summary> /// Tries to create an <see cref="ExecutionContext"/> from the <see cref="ContractsExecutionContext"/> present in a <see cref="CallRequestContext"/>. /// </summary> /// <param name="creator">This execution context creator.</param> /// <param name="requested">The execution context to use - typically from a Client request.</param> /// <returns>A <see cref="Try{TResult}"/> with a new <see cref="ExecutionContext"/> with the requested fields, if successful.</returns> public static Try <ExecutionContext> TryCreateUsing(this ICreateExecutionContexts creator, ContractsExecutionContext requested) => creator.TryCreateUsing(requested.ToExecutionContext());