本文整理汇总了Java中reactor.core.CoreSubscriber.onSubscribe方法的典型用法代码示例。如果您正苦于以下问题:Java CoreSubscriber.onSubscribe方法的具体用法?Java CoreSubscriber.onSubscribe怎么用?Java CoreSubscriber.onSubscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.core.CoreSubscriber
的用法示例。
在下文中一共展示了CoreSubscriber.onSubscribe方法的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: 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);
}
示例3: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super C> actual) {
C buffer;
try {
buffer = Objects.requireNonNull(bufferSupplier.get(),
"The bufferSupplier returned a null buffer");
}
catch (Throwable e) {
Operators.error(actual, Operators.onOperatorError(e, actual.currentContext()));
return;
}
BufferBoundaryMain<T, U, C> parent =
new BufferBoundaryMain<>(
source instanceof FluxInterval ?
actual : Operators.serialize(actual),
buffer, bufferSupplier);
actual.onSubscribe(parent);
other.subscribe(parent.other);
source.subscribe(parent);
}
示例4: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
Operators.MonoSubscriber<T, T>
sds = new Operators.MonoSubscriber<>(actual);
actual.onSubscribe(sds);
if (sds.isCancelled()) {
return;
}
try {
T t = supplier.get();
if (t == null) {
sds.onComplete();
}
else {
sds.complete(t);
}
}
catch (Throwable e) {
actual.onError(Operators.onOperatorError(e, actual.currentContext()));
}
}
示例5: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super Flux<T>> actual) {
WindowWhenMainSubscriber<T, U, V> main = new WindowWhenMainSubscriber<>(actual,
start, end, processorQueueSupplier);
actual.onSubscribe(main);
if (main.cancelled) {
return;
}
WindowWhenOpenSubscriber<T, U> os = new WindowWhenOpenSubscriber<>(main);
if (WindowWhenMainSubscriber.BOUNDARY.compareAndSet(main,null, os)) {
WindowWhenMainSubscriber.OPEN_WINDOW_COUNT.incrementAndGet(main);
start.subscribe(os);
source.subscribe(main);
}
}
示例6: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super Long> actual) {
Worker w = timedScheduler.createWorker();
IntervalRunnable r = new IntervalRunnable(actual, w);
actual.onSubscribe(r);
try {
w.schedulePeriodically(r, initialDelay, period, unit);
}
catch (RejectedExecutionException ree) {
if (!r.cancelled) {
actual.onError(Operators.onRejectedExecution(ree, r, null, null,
actual.currentContext()));
}
}
}
示例7: scanDelayRunnable
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Test
public void scanDelayRunnable() {
CoreSubscriber<Long> actual = new LambdaMonoSubscriber<>(null, e -> {
}, null, null);
MonoDelay.MonoDelayRunnable test = new MonoDelay.MonoDelayRunnable(actual);
actual.onSubscribe(test);
assertThat(test.scan(Scannable.Attr.PARENT)).isNull();
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.request(1);
test.run();
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
}
示例8: 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"));
}
}
示例9: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
T v = value;
if (v == null) {
ScheduledEmpty parent = new ScheduledEmpty(actual);
actual.onSubscribe(parent);
try {
parent.setFuture(scheduler.schedule(parent));
}
catch (RejectedExecutionException ree) {
if (parent.future != OperatorDisposables.DISPOSED) {
actual.onError(Operators.onRejectedExecution(ree,
actual.currentContext()));
}
}
}
else {
actual.onSubscribe(new ScheduledScalar<>(actual, v, scheduler));
}
}
示例10: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
Objects.requireNonNull(actual, "subscribe");
EmitterInner<T> inner = new EmitterInner<>(actual, this);
actual.onSubscribe(inner);
if (inner.isCancelled()) {
return;
}
if (add(inner)) {
if (inner.isCancelled()) {
remove(inner);
}
drain();
}
else {
Throwable e = error;
if (e != null) {
inner.actual.onError(e);
}
else {
inner.actual.onComplete();
}
}
}
示例11: apply
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public CoreSubscriber<? super T> apply(Scannable scannable, CoreSubscriber<? super T> coreSubscriber) {
return new CoreSubscriber<T>() {
@Override
public void onSubscribe(Subscription subscription) {
if (subscribedOnce.getAndSet(true)) {
throw new NullPointerException("You cannot directly subscribe to a gRPC service multiple times " +
"concurrently. Use Flux.share() instead.");
} else {
coreSubscriber.onSubscribe(subscription);
}
}
@Override
public void onNext(T t) {
coreSubscriber.onNext(t);
}
@Override
public void onError(Throwable throwable) {
coreSubscriber.onError(throwable);
}
@Override
public void onComplete() {
coreSubscriber.onComplete();
}
};
}
示例12: subscribeOnlyOnceLifterErrorsWhenMultipleSubscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Test
public void subscribeOnlyOnceLifterErrorsWhenMultipleSubscribe() throws Exception {
SubscribeOnlyOnceLifter<Object> op = new SubscribeOnlyOnceLifter<>();
CoreSubscriber<Object> innerSub = mock(CoreSubscriber.class);
Subscription subscription = mock(Subscription.class);
CoreSubscriber<Object> outerSub = op.apply(null, innerSub);
outerSub.onSubscribe(subscription);
assertThatThrownBy(() -> outerSub.onSubscribe(subscription))
.isInstanceOf(NullPointerException.class)
.hasMessageContaining("cannot directly subscribe to a gRPC service multiple times");
verify(innerSub, times(1)).onSubscribe(subscription);
}
示例13: startReceiver
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
final void startReceiver(CoreSubscriber<? super Object> s) {
if (receiver == null) {
if (log.isDebugEnabled()) {
log.debug("{} Subscribing inbound receiver [pending: {}, cancelled:{}, " +
"inboundDone: {}]", channel.toString(), getPending(),
isCancelled(),
inboundDone);
}
if (inboundDone && getPending() == 0) {
if (inboundError != null) {
Operators.error(s, inboundError);
return;
}
Operators.complete(s);
return;
}
receiver = s;
s.onSubscribe(this);
}
else {
Operators.error(s,
new IllegalStateException(
"Only one connection receive subscriber allowed."));
}
}
示例14: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
PublishInner<T> inner = new PublishInner<>(actual);
actual.onSubscribe(inner);
for (; ; ) {
if (inner.isCancelled()) {
break;
}
PublishSubscriber<T> c = connection;
if (c == null || c.isTerminated()) {
PublishSubscriber<T> u = new PublishSubscriber<>(prefetch, this);
if (!CONNECTION.compareAndSet(this, c, u)) {
continue;
}
c = u;
}
if (c.add(inner)) {
if (inner.isCancelled()) {
c.remove(inner);
}
else {
inner.parent = c;
}
c.drain();
break;
}
}
}
示例15: subscribe
import reactor.core.CoreSubscriber; //导入方法依赖的package包/类
@Override
public void subscribe(CoreSubscriber<? super T> actual) {
SampleFirstMain<T, U> main = new SampleFirstMain<>(actual, throttler);
actual.onSubscribe(main);
source.subscribe(main);
}