Search in sources :

Example 1 with BaseSubscriber

use of io.confluent.ksql.reactive.BaseSubscriber in project ksql by confluentinc.

the class BaseSubscriberWhiteboxVerificationTest method createSubscriber.

@Override
public Subscriber<JsonObject> createSubscriber(final WhiteboxSubscriberProbe<JsonObject> probe) {
    final Context context = vertx.getOrCreateContext();
    return new BaseSubscriber<JsonObject>(context) {

        private Subscription subscription;

        @Override
        protected void afterSubscribe(final Subscription subscription) {
            probe.registerOnSubscribe(new SubscriberPuppet() {

                @Override
                public void triggerRequest(long n) {
                    subscription.request(n);
                }

                @Override
                public void signalCancel() {
                    subscription.cancel();
                }
            });
            subscription.request(1);
            this.subscription = subscription;
        }

        @Override
        protected void handleValue(final JsonObject value) {
            probe.registerOnNext(value);
            subscription.request(1);
        }

        @Override
        protected void handleComplete() {
            probe.registerOnComplete();
        }

        @Override
        public void handleError(final Throwable t) {
            probe.registerOnError(t);
        }
    };
}
Also used : Context(io.vertx.core.Context) BaseSubscriber(io.confluent.ksql.reactive.BaseSubscriber) JsonObject(io.vertx.core.json.JsonObject) Subscription(org.reactivestreams.Subscription)

Example 2 with BaseSubscriber

use of io.confluent.ksql.reactive.BaseSubscriber in project ksql by confluentinc.

the class BaseSubscriberBlackboxVerificationTest method createSubscriber.

@Override
public Subscriber<JsonObject> createSubscriber() {
    final Context context = vertx.getOrCreateContext();
    return new BaseSubscriber<JsonObject>(context) {

        private Subscription subscription;

        @Override
        public synchronized void afterSubscribe(final Subscription s) {
            s.request(1);
            this.subscription = s;
        }

        @Override
        public synchronized void handleValue(final JsonObject jsonObject) {
            subscription.request(1);
        }
    };
}
Also used : Context(io.vertx.core.Context) BaseSubscriber(io.confluent.ksql.reactive.BaseSubscriber) JsonObject(io.vertx.core.json.JsonObject) Subscription(org.reactivestreams.Subscription)

Aggregations

BaseSubscriber (io.confluent.ksql.reactive.BaseSubscriber)2 Context (io.vertx.core.Context)2 JsonObject (io.vertx.core.json.JsonObject)2 Subscription (org.reactivestreams.Subscription)2