예제 #1
0
        /// <summary>
        /// Subscribes to the pub/sub-system and creates a new <see cref="Subscription"/>
        /// instance representing that subscriptions.
        /// </summary>
        /// <param name="operationContextPool">
        /// The operation context pool to rent context pools for execution.
        /// </param>
        /// <param name="queryExecutor">
        /// The query executor to process event payloads.
        /// </param>
        /// <param name="requestContext">
        /// The original request context.
        /// </param>
        /// <param name="queryPlan">
        /// The subscription query plan.
        /// </param>
        /// <param name="subscriptionType">
        /// The object type that represents the subscription.
        /// </param>
        /// <param name="rootSelections">
        /// The operation selection set.
        /// </param>
        /// <param name="resolveQueryRootValue">
        /// A delegate to resolve the subscription instance.
        /// </param>
        /// <param name="executionDiagnosticsEvents">
        /// The internal diagnostic events to report telemetry.
        /// </param>
        /// <returns>
        /// Returns a new subscription instance.
        /// </returns>
        public static async ValueTask <Subscription> SubscribeAsync(
            ObjectPool <OperationContext> operationContextPool,
            QueryExecutor queryExecutor,
            IRequestContext requestContext,
            QueryPlan queryPlan,
            ObjectType subscriptionType,
            ISelectionSet rootSelections,
            Func <object?> resolveQueryRootValue,
            IExecutionDiagnosticEvents executionDiagnosticsEvents)
        {
            var subscription = new Subscription(
                operationContextPool,
                queryExecutor,
                requestContext,
                queryPlan,
                subscriptionType,
                rootSelections,
                resolveQueryRootValue,
                executionDiagnosticsEvents);

            subscription._subscriptionScope =
                executionDiagnosticsEvents.ExecuteSubscription(subscription);

            subscription._sourceStream =
                await subscription.SubscribeAsync().ConfigureAwait(false);

            return(subscription);
        }
예제 #2
0
    public SubscriptionSession(
        CancellationTokenSource session,
        ISocketSessionInterceptor sessionInterceptor,
        ISocketConnection connection,
        IResponseStream responseStream,
        ISubscription subscription,
        IExecutionDiagnosticEvents diagnosticEvents,
        string clientSubscriptionId)
    {
        _session = session ??
                   throw new ArgumentNullException(nameof(session));
        _sessionInterceptor = sessionInterceptor ??
                              throw new ArgumentNullException(nameof(sessionInterceptor));
        _connection = connection ??
                      throw new ArgumentNullException(nameof(connection));
        _responseStream = responseStream ??
                          throw new ArgumentNullException(nameof(responseStream));
        _diagnosticEvents = diagnosticEvents ??
                            throw new ArgumentNullException(nameof(diagnosticEvents));
        Subscription = subscription ??
                       throw new ArgumentNullException(nameof(subscription));
        Id = clientSubscriptionId ??
             throw new ArgumentNullException(nameof(clientSubscriptionId));

        _sessionToken = _session.Token;

        Task.Factory.StartNew(
            SendResultsAsync,
            _sessionToken,
            TaskCreationOptions.LongRunning,
            TaskScheduler.Default);
    }
 public InstrumentationMiddleware(
     RequestDelegate next,
     IExecutionDiagnosticEvents diagnosticEvents)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
 }
예제 #4
0
 public SubscriptionExecutor(
     ObjectPool <OperationContext> operationContextPool,
     QueryExecutor queryExecutor,
     IExecutionDiagnosticEvents diagnosticEvents)
 {
     _operationContextPool = operationContextPool;
     _queryExecutor        = queryExecutor;
     _diagnosticEvents     = diagnosticEvents;
 }
예제 #5
0
 public SubscriptionEnumerable(
     ISourceStream sourceStream,
     Func <object, Task <IQueryResult> > onEvent,
     Subscription subscription,
     IExecutionDiagnosticEvents diagnosticEvents)
 {
     _sourceStream     = sourceStream;
     _onEvent          = onEvent;
     _subscription     = subscription;
     _diagnosticEvents = diagnosticEvents;
 }
예제 #6
0
 public DocumentParserMiddleware(
     RequestDelegate next,
     IExecutionDiagnosticEvents diagnosticEvents,
     IDocumentHashProvider documentHashProvider)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _documentHashProvider = documentHashProvider ??
                             throw new ArgumentNullException(nameof(documentHashProvider));
 }
예제 #7
0
 public ReadPersistedQueryMiddleware(
     RequestDelegate next,
     IExecutionDiagnosticEvents diagnosticEvents,
     IReadStoredQueries persistedQueryStore)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _persistedQueryStore = persistedQueryStore ??
                            throw new ArgumentNullException(nameof(persistedQueryStore));
 }
예제 #8
0
 public DocumentValidationMiddleware(
     RequestDelegate next,
     IExecutionDiagnosticEvents diagnosticEvents,
     IDocumentValidator documentValidator)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _documentValidator = documentValidator ??
                          throw new ArgumentNullException(nameof(documentValidator));
 }
예제 #9
0
 public OperationCacheMiddleware(
     RequestDelegate next,
     IExecutionDiagnosticEvents diagnosticEvents,
     IPreparedOperationCache operationCache)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _operationCache = operationCache ??
                       throw new ArgumentNullException(nameof(operationCache));
 }
예제 #10
0
 public SubscriptionEnumerator(
     IAsyncEnumerator <object> eventEnumerator,
     Func <object, Task <IQueryResult> > onEvent,
     Subscription subscription,
     IExecutionDiagnosticEvents diagnosticEvents,
     CancellationToken requestAborted)
 {
     _eventEnumerator  = eventEnumerator;
     _onEvent          = onEvent;
     _subscription     = subscription;
     _diagnosticEvents = diagnosticEvents;
     _requestAborted   = requestAborted;
 }
 public RegisteredExecutor(
     IRequestExecutor executor,
     IServiceProvider services,
     IExecutionDiagnosticEvents diagnosticEvents,
     RequestExecutorSetup setup,
     TypeModuleChangeMonitor typeModuleChangeMonitor)
 {
     Executor                = executor;
     Services                = services;
     DiagnosticEvents        = diagnosticEvents;
     Setup                   = setup;
     TypeModuleChangeMonitor = typeModuleChangeMonitor;
 }
예제 #12
0
 public DataStartMessageHandler(
     IRequestExecutor requestExecutor,
     ISocketSessionInterceptor socketSessionInterceptor,
     IErrorHandler errorHandler,
     IExecutionDiagnosticEvents diagnosticEvents)
 {
     _requestExecutor = requestExecutor ??
                        throw new ArgumentNullException(nameof(requestExecutor));
     _socketSessionInterceptor = socketSessionInterceptor ??
                                 throw new ArgumentNullException(nameof(socketSessionInterceptor));
     _errorHandler = errorHandler ??
                     throw new ArgumentNullException(nameof(errorHandler));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
 }
예제 #13
0
        private Subscription(
            ObjectPool <OperationContext> operationContextPool,
            QueryExecutor queryExecutor,
            IRequestContext requestContext,
            QueryPlan queryPlan,
            ObjectType subscriptionType,
            ISelectionSet rootSelections,
            Func <object?> resolveQueryRootValue,
            IExecutionDiagnosticEvents diagnosticEvents)
        {
            unchecked
            {
                _id++;
            }

            _operationContextPool  = operationContextPool;
            _queryExecutor         = queryExecutor;
            _requestContext        = requestContext;
            _queryPlan             = queryPlan;
            _subscriptionType      = subscriptionType;
            _rootSelections        = rootSelections;
            _resolveQueryRootValue = resolveQueryRootValue;
            _diagnosticEvents      = diagnosticEvents;
        }