Exemple #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="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="diagnosticsEvents">
            /// 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,
                ObjectType subscriptionType,
                ISelectionSet rootSelections,
                Func <object?> resolveQueryRootValue,
                IDiagnosticEvents diagnosticsEvents)
            {
                var subscription = new Subscription(
                    operationContextPool,
                    queryExecutor,
                    requestContext,
                    subscriptionType,
                    rootSelections,
                    resolveQueryRootValue,
                    diagnosticsEvents);

                subscription._subscriptionScope =
                    diagnosticsEvents.ExecuteSubscription(subscription);

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

                return(subscription);
            }
Exemple #2
0
 public RequestExecutor(
     ISchema schema,
     IServiceProvider applicationServices,
     IServiceProvider executorServices,
     IErrorHandler errorHandler,
     ITypeConverter converter,
     IActivator activator,
     IDiagnosticEvents diagnosticEvents,
     RequestDelegate requestDelegate)
 {
     Schema = schema ??
              throw new ArgumentNullException(nameof(schema));
     _services = applicationServices ??
                 throw new ArgumentNullException(nameof(applicationServices));
     Services = executorServices ??
                throw new ArgumentNullException(nameof(executorServices));
     _errorHandler = errorHandler ??
                     throw new ArgumentNullException(nameof(errorHandler));
     _converter = converter ??
                  throw new ArgumentNullException(nameof(converter));
     _activator = activator ??
                  throw new ArgumentNullException(nameof(activator));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _requestDelegate = requestDelegate ??
                        throw new ArgumentNullException(nameof(requestDelegate));
     _batchExecutor = new BatchExecutor(this, errorHandler, converter);
 }
        public SubscriptionSession(
            ISocketConnection connection,
            IResponseStream responseStream,
            ISubscription subscription,
            IDiagnosticEvents diagnosticEvents,
            string clientSubscriptionId)
        {
            _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));

            _cts = CancellationTokenSource.CreateLinkedTokenSource(_connection.RequestAborted);

            Task.Factory.StartNew(
                SendResultsAsync,
                _cts.Token,
                TaskCreationOptions.LongRunning,
                TaskScheduler.Default);
        }
 public SubscriptionExecutor(
     ObjectPool <OperationContext> operationContextPool,
     QueryExecutor queryExecutor,
     IDiagnosticEvents diagnosticEvents)
 {
     _operationContextPool = operationContextPool;
     _queryExecutor        = queryExecutor;
     _diagnosticEvents     = diagnosticEvents;
 }
Exemple #5
0
 public InstrumentationMiddleware(
     RequestDelegate next,
     IDiagnosticEvents diagnosticEvents)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
 }
 public RegisteredExecutor(
     IRequestExecutor executor,
     IServiceProvider services,
     IDiagnosticEvents diagnosticEvents,
     RequestExecutorSetup setup)
 {
     Executor         = executor;
     Services         = services;
     DiagnosticEvents = diagnosticEvents;
     Setup            = setup;
 }
 public ReadPersistedQueryMiddleware(
     RequestDelegate next,
     IDiagnosticEvents diagnosticEvents,
     IReadStoredQueries persistedQueryStore)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _persistedQueryStore = persistedQueryStore ??
                            throw new ArgumentNullException(nameof(persistedQueryStore));
 }
Exemple #8
0
 public DataStartMessageHandler(
     IRequestExecutor requestExecutor,
     ISocketSessionInterceptor socketSessionInterceptor,
     IDiagnosticEvents diagnosticEvents)
 {
     _requestExecutor = requestExecutor ??
                        throw new ArgumentNullException(nameof(requestExecutor));
     _socketSessionInterceptor = socketSessionInterceptor ??
                                 throw new ArgumentNullException(nameof(socketSessionInterceptor));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
 }
 public DocumentValidationMiddleware(
     RequestDelegate next,
     IDiagnosticEvents diagnosticEvents,
     IDocumentValidator documentValidator)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _documentValidator = documentValidator ??
                          throw new ArgumentNullException(nameof(documentValidator));
 }
Exemple #10
0
 public OperationVariableCoercionMiddleware(
     RequestDelegate next,
     IDiagnosticEvents diagnosticEvents,
     VariableCoercionHelper coercionHelper)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _coercionHelper = coercionHelper ??
                       throw new ArgumentNullException(nameof(coercionHelper));
 }
 public OperationCacheMiddleware(
     RequestDelegate next,
     IDiagnosticEvents diagnosticEvents,
     IPreparedOperationCache operationCache)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _operationCache = operationCache ??
                       throw new ArgumentNullException(nameof(operationCache));
 }
Exemple #12
0
 public DocumentCacheMiddleware(
     RequestDelegate next,
     IDiagnosticEvents diagnosticEvents,
     IDocumentCache documentCache,
     IDocumentHashProvider documentHashProvider)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _documentCache = documentCache ??
                      throw new ArgumentNullException(nameof(documentCache));
     _documentHashProvider = documentHashProvider ??
                             throw new ArgumentNullException(nameof(documentHashProvider));
 }
Exemple #13
0
 private Subscription(
     ObjectPool <OperationContext> operationContextPool,
     QueryExecutor queryExecutor,
     IRequestContext requestContext,
     ObjectType subscriptionType,
     ISelectionSet rootSelections,
     IDiagnosticEvents diagnosticEvents)
 {
     _operationContextPool = operationContextPool;
     _queryExecutor        = queryExecutor;
     _requestContext       = requestContext;
     _subscriptionType     = subscriptionType;
     _rootSelections       = rootSelections;
     _diagnosticEvents     = diagnosticEvents;
 }
 public WritePersistedQueryMiddleware(
     RequestDelegate next,
     IDiagnosticEvents diagnosticEvents,
     IDocumentHashProvider documentHashProvider,
     IWriteStoredQueries persistedQueryStore)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _hashProvider = documentHashProvider ??
                     throw new ArgumentNullException(nameof(documentHashProvider));
     _persistedQueryStore = persistedQueryStore ??
                            throw new ArgumentNullException(nameof(persistedQueryStore));
 }
        public OperationResolverMiddleware(
            RequestDelegate next,
            IDiagnosticEvents diagnosticEvents,
            IEnumerable <ISelectionOptimizer> optimizers)
        {
            if (optimizers is null)
            {
                throw new ArgumentNullException(nameof(optimizers));
            }

            _next = next ??
                    throw new ArgumentNullException(nameof(next));
            _diagnosticEvents = diagnosticEvents ??
                                throw new ArgumentNullException(nameof(diagnosticEvents));
            _optimizers = optimizers.ToArray();
        }
 public RequestContext(
     ISchema schema,
     IServiceProvider services,
     IErrorHandler errorHandler,
     ITypeConverter converter,
     IActivator activator,
     IDiagnosticEvents diagnosticEvents,
     IQueryRequest request)
 {
     Schema           = schema;
     Services         = services;
     ErrorHandler     = errorHandler;
     Converter        = converter;
     Activator        = activator;
     DiagnosticEvents = diagnosticEvents;
     Request          = request;
     ContextData      = request.ContextData is null
         ? new ConcurrentDictionary <string, object?>()
         : new ConcurrentDictionary <string, object?>(request.ContextData);
 }
Exemple #17
0
            public static async ValueTask <Subscription> SubscribeAsync(
                ObjectPool <OperationContext> operationContextPool,
                QueryExecutor queryExecutor,
                IRequestContext requestContext,
                ObjectType subscriptionType,
                ISelectionSet rootSelections,
                IDiagnosticEvents diagnosicEvents)
            {
                var subscription = new Subscription(
                    operationContextPool,
                    queryExecutor,
                    requestContext,
                    subscriptionType,
                    rootSelections,
                    diagnosicEvents);

                subscription._sourceStream = await subscription.SubscribeAsync();

                return(subscription);
            }
 public OperationExecutionMiddleware(
     RequestDelegate next,
     IDiagnosticEvents diagnosticEvents,
     ObjectPool <OperationContext> operationContextPool,
     QueryExecutor queryExecutor,
     MutationExecutor mutationExecutor,
     SubscriptionExecutor subscriptionExecutor)
 {
     _next = next ??
             throw new ArgumentNullException(nameof(next));
     _diagnosticEvents = diagnosticEvents ??
                         throw new ArgumentNullException(nameof(diagnosticEvents));
     _operationContextPool = operationContextPool ??
                             throw new ArgumentNullException(nameof(operationContextPool));
     _queryExecutor = queryExecutor ??
                      throw new ArgumentNullException(nameof(queryExecutor));
     _mutationExecutor = mutationExecutor ??
                         throw new ArgumentNullException(nameof(mutationExecutor));
     _subscriptionExecutor = subscriptionExecutor ??
                             throw new ArgumentNullException(nameof(subscriptionExecutor));
 }
Exemple #19
0
            private Subscription(
                ObjectPool <OperationContext> operationContextPool,
                QueryExecutor queryExecutor,
                IRequestContext requestContext,
                ObjectType subscriptionType,
                ISelectionSet rootSelections,
                Func <object?> resolveQueryRootValue,
                IDiagnosticEvents diagnosticEvents)
            {
                unchecked
                {
                    _id++;
                }

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