Class PythonAsyncioStreams.PublisherIterator
java.lang.Object
io.micronaut.context.python.PythonAsyncioStreams.PublisherIterator
- All Implemented Interfaces:
Subscriber<Object>
- Enclosing class:
PythonAsyncioStreams
@Internal
public static final class PythonAsyncioStreams.PublisherIterator
extends Object
implements Subscriber<Object>
Subscribes to a publisher one item at a time on behalf of a Python async iterator.
The subscription is lazy: the first request() subscribes. Every request asks for one
item; requests made before onSubscribe arrives are accumulated. Signals reach the
Python callbacks through PythonAsyncioStreams.dispatch(PythonEventLoop, Context, Runnable, Runnable), and once the context refuses the frame (it is
closing) the subscription is cancelled so no further signals are attempted.
- Since:
- 5.2.3
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Cancel the subscription; later signals are ignored.booleanvoidvoidvoidvoidonSubscribe(Subscription subscription) voidrequest()Request one more item, subscribing first when this is the first request.
-
Method Details
-
request
public void request()Request one more item, subscribing first when this is the first request. -
cancel
public void cancel()Cancel the subscription; later signals are ignored. Idempotent. -
isCancelled
public boolean isCancelled()- Returns:
- Whether the subscription was cancelled from the Python side
-
onSubscribe
- Specified by:
onSubscribein interfaceSubscriber<Object>
-
onNext
- Specified by:
onNextin interfaceSubscriber<Object>
-
onError
- Specified by:
onErrorin interfaceSubscriber<Object>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceSubscriber<Object>
-