本文整理汇总了Java中reactor.core.CoreSubscriber类的典型用法代码示例。如果您正苦于以下问题:Java CoreSubscriber类的具体用法?Java CoreSubscriber怎么用?Java CoreSubscriber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CoreSubscriber类属于reactor.core包,在下文中一共展示了CoreSubscriber类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribe
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Override
public final void subscribe(final CoreSubscriber<? super Void> s) {
if(future.isDone()){
if(future.isSuccess()){
Operators.complete(s);
}
else{
Operators.error(s, future.cause());
}
return;
}
FutureSubscription<F> fs = new FutureSubscription<>(future, s);
s.onSubscribe(fs);
future.addListener(fs);
}
示例2: scanThenAcceptInner
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Test
public void scanThenAcceptInner() {
CoreSubscriber<String> actual = new LambdaMonoSubscriber<>(null, e -> {}, null, null);
MonoIgnoreThen.ThenIgnoreMain<String> main = new MonoIgnoreThen.ThenIgnoreMain<>(actual, new Publisher[0], Mono.just("foo"));
MonoIgnoreThen.ThenAcceptInner<String> test = new MonoIgnoreThen.ThenAcceptInner<>(main);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(main);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onError(new IllegalStateException("boom"));
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例3: scanInner
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Test
public void scanInner() {
CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxFilterWhen.FluxFilterWhenSubscriber<String> main = new FluxFilterWhen.FluxFilterWhenSubscriber<>(actual, t -> Mono.just(true), 789);
FluxFilterWhen.FilterWhenInner test = new FluxFilterWhen.FilterWhenInner(main, true);
Subscription sub = Operators.emptySubscription();
test.onSubscribe(sub);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(main);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(sub);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(1L);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onNext(false);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(0L);
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例4: scanPostOnSubscribeSubscriber
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Test
public void scanPostOnSubscribeSubscriber() {
CoreSubscriber<String> s = new LambdaSubscriber<>(null, null, null, null);
StrictSubscriber<String> test = new StrictSubscriber<>(s);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(s);
assertThat(test.scan(Scannable.Attr.PARENT)).isNull();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(0L);
test.request(2);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(2L);
Subscription parent = Operators.cancelledSubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例5: subscribe
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super R> actual) {
JoinSubscription<TLeft, TRight, TLeftEnd, TRightEnd, R> parent =
new JoinSubscription<>(actual,
leftEnd,
rightEnd,
resultSelector,
queueSupplier.get());
actual.onSubscribe(parent);
LeftRightSubscriber left = new LeftRightSubscriber(parent, true);
parent.cancellations.add(left);
LeftRightSubscriber right = new LeftRightSubscriber(parent, false);
parent.cancellations.add(right);
source.subscribe(left);
other.subscribe(right);
}
示例6: scanSubscriberCancelled
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Test
public void scanSubscriberCancelled() {
CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxDetach.DetachSubscriber<String> test = new FluxDetach.DetachSubscriber<>(actual);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.PARENT)).isNull();
assertThat(test.scan(Scannable.Attr.ACTUAL)).isNull();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
}
示例7: scanOtherSubscriber
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Test
public void scanOtherSubscriber() {
CoreSubscriber<String> actual = new LambdaSubscriber<>(null, e -> {}, null,
sub -> sub.request(100));
FluxDelaySubscription.DelaySubscriptionOtherSubscriber<String, Integer> test = new FluxDelaySubscription.DelaySubscriptionOtherSubscriber<String, Integer>(
actual, s -> {});
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(100L);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onError(new IllegalStateException("boom"));
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例8: scanHasElements
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Test
public void scanHasElements() {
CoreSubscriber<? super Boolean> actual = new LambdaMonoSubscriber<>(null, e -> {}, null, null);
MonoHasElements.HasElementsSubscriber<String> test = new MonoHasElements.HasElementsSubscriber<>(actual);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.onComplete();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
}
示例9: scanMultiSubscriptionSubscriber
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Test
public void scanMultiSubscriptionSubscriber() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, null, null, null);
MultiSubscriptionSubscriber<Integer, Integer> test = new MultiSubscriptionSubscriber<Integer, Integer>(actual) {
@Override
public void onNext(Integer t) {
}
};
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
test.request(34);
Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(34);
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例10: scanSubscriber
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Test
public void scanSubscriber() {
CoreSubscriber<Boolean> actual = new LambdaMonoSubscriber<>(null, e -> {}, null, null);
MonoAny.AnySubscriber<String> test = new MonoAny.AnySubscriber<>(actual, String::isEmpty);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onError(new IllegalStateException("boom"));
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例11: scanMulticastInner
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Test
public void scanMulticastInner() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxPublishMulticast.FluxPublishMulticaster<Integer> parent =
new FluxPublishMulticast.FluxPublishMulticaster<>(123, Queues.<Integer>unbounded(), Context.empty());
FluxPublishMulticast.PublishMulticastInner<Integer> test =
new FluxPublishMulticast.PublishMulticastInner<>(parent, actual);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
test.request(789);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(789);
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例12: subscribe
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
Objects.requireNonNull(actual, "subscribe");
if (once == 0 && ONCE.compareAndSet(this, 0, 1)) {
actual.onSubscribe(this);
this.actual = actual;
if (cancelled) {
this.actual = null;
} else {
drain();
}
} else {
Operators.error(actual, new IllegalStateException("UnicastProcessor " +
"allows only a single Subscriber"));
}
}
示例13: subscribe
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void subscribe(CoreSubscriber<? super T> actual) {
Publisher<? extends T> p;
try {
p = Objects.requireNonNull(supplier.get(),
"The Publisher returned by the supplier is null");
}
catch (Throwable e) {
Operators.error(actual, Operators.onOperatorError(e, actual.currentContext()));
return;
}
from(p).subscribe(actual);
}
示例14: scanMain
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Test
public void scanMain() {
CoreSubscriber<? super List> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
List<String> initialBuffer = Arrays.asList("foo", "bar");
FluxBufferBoundary.BufferBoundaryMain<String, Integer, List<String>> test = new FluxBufferBoundary.BufferBoundaryMain<>(
actual, initialBuffer, ArrayList::new);
Subscription parent = Operators.cancelledSubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.CAPACITY)).isEqualTo(2);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(0L);
test.request(2);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(2L);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
示例15: scanSubscriber
import reactor.core.CoreSubscriber; //导入依赖的package包/类
@Test
public void scanSubscriber() {
CoreSubscriber<Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null);
FluxPeek<Integer> peek = new FluxPeek<>(Flux.just(1), s -> {}, s -> {},
e -> {}, () -> {}, () -> {}, r -> {}, () -> {});
FluxPeek.PeekSubscriber<Integer> test = new FluxPeek.PeekSubscriber<>(actual, peek);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onError(new IllegalStateException("boom"));
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
}