Interface SseClient


  • public interface SseClient
    A client for streaming Server Sent Event streams.
    Since:
    1.0
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      static SseClient create​(java.net.URL url)
      Create a new SseClient.
      static SseClient create​(java.net.URL url, HttpClientConfiguration configuration)
      Create a new SseClient with the specified configuration.
      <I> org.reactivestreams.Publisher<io.micronaut.http.sse.Event<io.micronaut.core.io.buffer.ByteBuffer<?>>> eventStream​(io.micronaut.http.HttpRequest<I> request)
      Perform an HTTP request and receive data as a stream of SSE Event objects as they become available without blocking.
      <I,​B>
      org.reactivestreams.Publisher<io.micronaut.http.sse.Event<B>>
      eventStream​(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<B> eventType)
      Perform an HTTP request and receive data as a stream of SSE Event objects as they become available without blocking.
      <I,​B>
      org.reactivestreams.Publisher<io.micronaut.http.sse.Event<B>>
      eventStream​(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<B> eventType, io.micronaut.core.type.Argument<?> errorType)
      Perform an HTTP request and receive data as a stream of SSE Event objects as they become available without blocking.
      default <I,​B>
      org.reactivestreams.Publisher<io.micronaut.http.sse.Event<B>>
      eventStream​(io.micronaut.http.HttpRequest<I> request, java.lang.Class<B> eventType)
      Perform an HTTP request and receive data as a stream of SSE Event objects as they become available without blocking.
      default <B> org.reactivestreams.Publisher<io.micronaut.http.sse.Event<B>> eventStream​(java.lang.String uri, io.micronaut.core.type.Argument<B> eventType)
      Perform an HTTP GET request and receive data as a stream of SSE Event objects as they become available without blocking.
      default <B> org.reactivestreams.Publisher<io.micronaut.http.sse.Event<B>> eventStream​(java.lang.String uri, java.lang.Class<B> eventType)
      Perform an HTTP GET request and receive data as a stream of SSE Event objects as they become available without blocking.
    • Method Detail

      • eventStream

        <I> org.reactivestreams.Publisher<io.micronaut.http.sse.Event<io.micronaut.core.io.buffer.ByteBuffer<?>>> eventStream​(@NonNull
                                                                                                                              io.micronaut.http.HttpRequest<I> request)

        Perform an HTTP request and receive data as a stream of SSE Event objects as they become available without blocking.

        The downstream Subscriber can regulate demand via the subscription

        Type Parameters:
        I - The request body type
        Parameters:
        request - The HttpRequest to execute
        Returns:
        A Publisher that emits an Event with the data represented as a ByteBuffer
      • eventStream

        <I,​B> org.reactivestreams.Publisher<io.micronaut.http.sse.Event<B>> eventStream​(@NonNull
                                                                                              io.micronaut.http.HttpRequest<I> request,
                                                                                              @NonNull
                                                                                              io.micronaut.core.type.Argument<B> eventType)

        Perform an HTTP request and receive data as a stream of SSE Event objects as they become available without blocking.

        The downstream Subscriber can regulate demand via the subscription

        Type Parameters:
        I - The request body type
        B - The event body type
        Parameters:
        request - The HttpRequest to execute
        eventType - The event data type
        Returns:
        A Publisher that emits an Event with the data represented by the eventType argument
      • eventStream

        <I,​B> org.reactivestreams.Publisher<io.micronaut.http.sse.Event<B>> eventStream​(@NonNull
                                                                                              io.micronaut.http.HttpRequest<I> request,
                                                                                              @NonNull
                                                                                              io.micronaut.core.type.Argument<B> eventType,
                                                                                              @NonNull
                                                                                              io.micronaut.core.type.Argument<?> errorType)

        Perform an HTTP request and receive data as a stream of SSE Event objects as they become available without blocking.

        The downstream Subscriber can regulate demand via the subscription

        Type Parameters:
        I - The request body type
        B - The event body type
        Parameters:
        request - The HttpRequest to execute
        eventType - The event data type
        errorType - The type that the response body should be coerced into if the server responds with an error
        Returns:
        A Publisher that emits an Event with the data represented by the eventType argument
        Since:
        3.1.0
      • eventStream

        default <I,​B> org.reactivestreams.Publisher<io.micronaut.http.sse.Event<B>> eventStream​(@NonNull
                                                                                                      io.micronaut.http.HttpRequest<I> request,
                                                                                                      @NonNull
                                                                                                      java.lang.Class<B> eventType)

        Perform an HTTP request and receive data as a stream of SSE Event objects as they become available without blocking.

        The downstream Subscriber can regulate demand via the subscription

        Type Parameters:
        I - The request body type
        B - The event body type
        Parameters:
        request - The HttpRequest to execute
        eventType - The event data type
        Returns:
        A Publisher that emits an Event with the data represented by the eventType argument
      • eventStream

        default <B> org.reactivestreams.Publisher<io.micronaut.http.sse.Event<B>> eventStream​(@NonNull
                                                                                              java.lang.String uri,
                                                                                              @NonNull
                                                                                              java.lang.Class<B> eventType)

        Perform an HTTP GET request and receive data as a stream of SSE Event objects as they become available without blocking.

        The downstream Subscriber can regulate demand via the subscription

        Type Parameters:
        B - The event body type
        Parameters:
        uri - The request URI
        eventType - The event data type
        Returns:
        A Publisher that emits an Event with the data represented by the eventType argument
      • eventStream

        default <B> org.reactivestreams.Publisher<io.micronaut.http.sse.Event<B>> eventStream​(@NonNull
                                                                                              java.lang.String uri,
                                                                                              @NonNull
                                                                                              io.micronaut.core.type.Argument<B> eventType)

        Perform an HTTP GET request and receive data as a stream of SSE Event objects as they become available without blocking.

        The downstream Subscriber can regulate demand via the subscription

        Type Parameters:
        B - The event body type
        Parameters:
        uri - The request URI
        eventType - The event data type
        Returns:
        A Publisher that emits an Event with the data represented by the eventType argument
      • create

        static SseClient create​(@Nullable
                                java.net.URL url)
        Create a new SseClient. Note that this method should only be used outside of the context of a Micronaut application. The returned SseClient is not subject to dependency injection. The creator is responsible for closing the client to avoid leaking connections. Within a Micronaut application use Inject to inject a client instead.
        Parameters:
        url - The base URL
        Returns:
        The client
      • create

        static SseClient create​(@Nullable
                                java.net.URL url,
                                @NonNull
                                HttpClientConfiguration configuration)
        Create a new SseClient with the specified configuration. Note that this method should only be used outside of the context of an application. Within Micronaut use Inject to inject a client instead
        Parameters:
        url - The base URL
        configuration - the client configuration
        Returns:
        The client
        Since:
        2.2.0