Java Code Examples for reactor.core.publisher.FluxSink#onCancel()
The following examples show how to use
reactor.core.publisher.FluxSink#onCancel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FluxMethodBridge.java From titus-control-plane with Apache License 2.0 | 5 votes |
private FluxInvocation(FluxSink<Object> sink, Object[] args) { StreamObserver<Object> grpcStreamObserver = new ClientResponseObserver<Object, Object>() { @Override public void beforeStart(ClientCallStreamObserver requestStream) { sink.onCancel(() -> requestStream.cancel("React subscription cancelled", null)); } @Override public void onNext(Object value) { sink.next(value); } @Override public void onError(Throwable error) { sink.error(error); } @Override public void onCompleted() { sink.complete(); } }; Object[] grpcArgs = new Object[]{ grpcArgPos < 0 ? Empty.getDefaultInstance() : args[grpcArgPos], grpcStreamObserver }; GRPC_STUB invocationStub = handleCallMetadata(args) .withDeadline(Deadline.after(timeout.toMillis(), TimeUnit.MILLISECONDS)); try { grpcMethod.invoke(invocationStub, grpcArgs); } catch (Exception e) { sink.error(e); } }
Example 2
Source File: DefaultManyReconciler.java From titus-control-plane with Apache License 2.0 | 5 votes |
private void connectEventListeners() { if (eventListenerHolders.isEmpty()) { return; } for (EventListenerHolder holder; (holder = eventListenerHolders.poll()) != null; ) { FluxSink<List<SimpleReconcilerEvent<DATA>>> sink = holder.getSink(); Disposable disposable = eventStream.subscribe(sink::next, sink::error); sink.onCancel(disposable); } }
Example 3
Source File: FluxObservableEmitter.java From titus-control-plane with Apache License 2.0 | 4 votes |
@Override public void accept(FluxSink<T> sink) { Subscription subscription = source.subscribe(sink::next, sink::error, sink::complete); sink.onCancel(subscription::unsubscribe); }