io.axoniq.flowcontrol.consumer.grpc.client.ClientResponseObserverSubscription Maven / Gradle / Ivy
/*
* Copyright (c) 2021. AxonIQ
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.axoniq.flowcontrol.consumer.grpc.client;
import io.grpc.stub.ClientCallStreamObserver;
import io.grpc.stub.ClientResponseObserver;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
/**
* A reactive streams {@link Subscription} that also plays a role as gRPC {@link ClientResponseObserver}. All signals
* (messages, errors, completes) received from the gRPC communication channel are going to be forwarded to the
* subscriber of this subscription. Of course, the backpressure is respected.
*
* @param the type of message being transmitted via this observer
* @author Sara Pellegrini
* @author Milan Savic
* @since 1.0
*/
class ClientResponseObserverSubscription implements ClientResponseObserver