コード例 #1
0
        public void Initialize(
            IBatchDispatcher batchDispatcher,
            CancellationToken requestAborted)
        {
            _completed = new CancellationTokenSource();
            requestAborted.Register(TryComplete);

            BatchDispatcher = batchDispatcher;
            BatchDispatcher.TaskEnqueued += BatchDispatcherEventHandler;
        }
コード例 #2
0
        public void Initialize(
            IBatchDispatcher batchDispatcher,
            CancellationToken requestAborted)
        {
            _taskStatistics.Clear();

            _completed = new CancellationTokenSource();
            requestAborted.Register(TryComplete);

            _batchDispatcher = batchDispatcher;
            _batchDispatcher.TaskEnqueued += BatchDispatcherEventHandler;

            _isPooled = false;
        }
コード例 #3
0
 public void Initialize(
     IRequestContext requestContext,
     IServiceProvider scopedServices,
     IBatchDispatcher batchDispatcher,
     IPreparedOperation operation,
     object?rootValue,
     IVariableValueCollection variables)
 {
     _requestContext = requestContext;
     _executionContext.Initialize(
         batchDispatcher,
         requestContext.RequestAborted);
     Operation = operation;
     RootValue = rootValue;
     Variables = variables;
     Services  = scopedServices;
 }
コード例 #4
0
            private async Task <IQueryResult> OnEvent(object payload)
            {
                using IServiceScope serviceScope = _requestContext.Services.CreateScope();

                IServiceProvider eventServices = serviceScope.ServiceProvider;
                IBatchDispatcher dispatcher    = eventServices.GetRequiredService <IBatchDispatcher>();

                OperationContext operationContext = _operationContextPool.Get();

                try
                {
                    ImmutableDictionary <string, object?> scopedContext =
                        ImmutableDictionary <string, object?> .Empty
                        .SetItem(WellKnownContextData.EventMessage, payload);

                    object?rootValue = RootValueResolver.Resolve(
                        _requestContext,
                        eventServices,
                        _subscriptionType,
                        ref _cachedRootValue);

                    operationContext.Initialize(
                        _requestContext,
                        eventServices,
                        dispatcher,
                        _requestContext.Operation !,
                        _requestContext.Variables !,
                        rootValue,
                        _resolveQueryRootValue);

                    return(await _queryExecutor
                           .ExecuteAsync(operationContext, scopedContext)
                           .ConfigureAwait(false));
                }
                finally
                {
                    _operationContextPool.Return(operationContext);
                }
            }
コード例 #5
0
 public void Clean()
 {
     if (_batchDispatcher is not null !)
     {
         _batchDispatcher.TaskEnqueued -= BatchDispatcherEventHandler;
         _batchDispatcher = default !;
コード例 #6
0
 public async ValueTask InvokeAsync(
     IRequestContext context,
     IBatchDispatcher batchDispatcher)
 {
     if (context.Operation is { } && context.Variables is { })