All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.salesforce.rxgrpc.stub.RxSubscriberAndServerProducer Maven / Gradle / Ivy

The newest version!
/*
 *  Copyright (c) 2019, Salesforce.com, Inc.
 *  All rights reserved.
 *  Licensed under the BSD 3-Clause license.
 *  For full license text, see LICENSE.txt file in the repo root  or https://opensource.org/licenses/BSD-3-Clause
 */

package com.salesforce.rxgrpc.stub;

import com.salesforce.reactivegrpc.common.AbstractSubscriberAndServerProducer;
import com.salesforce.reactivegrpc.common.Function;
import io.reactivex.FlowableSubscriber;
import io.reactivex.internal.fuseable.QueueSubscription;
import org.reactivestreams.Subscription;

/**
 * The gRPC server-side implementation of {@link com.salesforce.reactivegrpc.common.AbstractSubscriberAndProducer}.
 *
 * @param  T
 */
public class RxSubscriberAndServerProducer
        extends AbstractSubscriberAndServerProducer
        implements FlowableSubscriber {

    public RxSubscriberAndServerProducer(Function prepareError) {
        super(prepareError);
    }

    @Override
    protected Subscription fuse(Subscription s) {
        if (s instanceof QueueSubscription) {
            @SuppressWarnings("unchecked")
            QueueSubscription f = (QueueSubscription) s;

            int m = f.requestFusion(QueueSubscription.ANY);

            if (m != QueueSubscription.NONE) {
                return new FusionAwareQueueSubscriptionAdapter(f, m);
            }
        }

        return s;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy