Beispiel #1
0
    public virtual async ValueTask OnReplicaRequest(ReplicaRequest request, CancellationToken cancellationToken)
    {
        if (request.PublisherId != Publisher.Id)
        {
            await OnUnsupportedRequest(request, cancellationToken).ConfigureAwait(false);

            return;
        }
        var publicationId = request.PublicationId;
        var publication   = Publisher.Get(publicationId);

        if (publication == null)
        {
            await OnUnsupportedRequest(request, cancellationToken).ConfigureAwait(false);

            return;
        }
        if (Subscriptions.TryGetValue(publicationId, out var subscriptionProcessor))
        {
            goto subscriptionExists;
        }
        lock (Lock) {
            // Double check locking
            if (Subscriptions.TryGetValue(publicationId, out subscriptionProcessor))
            {
                goto subscriptionExists;
            }

            subscriptionProcessor = PublisherImpl.SubscriptionProcessorFactory.Create(
                PublisherImpl.SubscriptionProcessorGeneric,
                publication, Channel, PublisherImpl.SubscriptionExpirationTime,
                PublisherImpl.Clocks, Services);
            Subscriptions[publicationId] = subscriptionProcessor;
        }
        _ = subscriptionProcessor.Run(default)
Beispiel #2
0
 public static IPublication Get(
     this IPublisher publisher, Symbol publicationId)
 => publisher.Get(publicationId) ?? throw new KeyNotFoundException();