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

com.salesforce.rx3grpc.stub.RxSubscriberAndClientProducer Maven / Gradle / Ivy

/*
 *  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.rx3grpc.stub;

import org.reactivestreams.Subscription;

import com.salesforce.reactivegrpc.common.AbstractSubscriberAndClientProducer;

import io.reactivex.rxjava3.core.FlowableSubscriber;
import io.reactivex.rxjava3.operators.QueueSubscription;

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

    @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