Exemplo n.º 1
0
    async Task <bool> RejectIfInvalidDefinition(
        EmbeddingDefinition definition,
        IReverseCallDispatcher <EmbeddingClientToRuntimeMessage, EmbeddingRuntimeToClientMessage, EmbeddingRegistrationRequest, EmbeddingRegistrationResponse, EmbeddingRequest, EmbeddingResponse> dispatcher,
        CancellationToken cancellationToken)
    {
        _logger.ComparingEmbeddingDefinition(definition);
        var tenantsAndComparisonResult = await _embeddingDefinitionComparer.DiffersFromPersisted(
            new EmbeddingDefinition(
                definition.Embedding,
                definition.Events,
                definition.InititalState),
            cancellationToken).ConfigureAwait(false);

        if (tenantsAndComparisonResult.Values.All(_ => _.Succeeded))
        {
            return(false);
        }

        var unsuccessfulComparisons = tenantsAndComparisonResult
                                      .Where(_ => !_.Value.Succeeded)
                                      .Select(_ => (_.Key, _.Value));

        _logger.InvalidEmbeddingDefinition(definition, unsuccessfulComparisons);

        await dispatcher.Reject(CreateInvalidValidationResponse(
                                    unsuccessfulComparisons,
                                    definition.Embedding),
                                cancellationToken).ConfigureAwait(false);


        return(true);
    }
Exemplo n.º 2
0
 Task WriteFailedRegistrationResponse <TClientMessage, TConnectRequest, TResponse>(
     IReverseCallDispatcher <TClientMessage, FilterRuntimeToClientMessage, TConnectRequest, FilterRegistrationResponse, FilterEventRequest, TResponse> dispatcher,
     Failure failure,
     CancellationToken cancellationToken)
     where TClientMessage : IMessage, new()
     where TConnectRequest : class
     where TResponse : class => dispatcher.Reject(new FilterRegistrationResponse {
     Failure = failure
 }, cancellationToken);
Exemplo n.º 3
0
 Task WriteFailedRegistrationResponse(
     IReverseCallDispatcher <EventHandlerClientToRuntimeMessage, EventHandlerRuntimeToClientMessage, EventHandlerRegistrationRequest, EventHandlerRegistrationResponse, HandleEventRequest, EventHandlerResponse> dispatcher,
     Failure failure,
     CancellationToken cancellationToken) => dispatcher.Reject(new EventHandlerRegistrationResponse {
     Failure = failure
 }, cancellationToken);