All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.micronaut.http.client.sse.SseClient Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2017-2018 original authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.micronaut.http.client.sse;

import io.micronaut.core.io.buffer.ByteBuffer;
import io.micronaut.core.type.Argument;
import io.micronaut.http.HttpRequest;
import io.micronaut.http.sse.Event;
import org.reactivestreams.Publisher;

/**
 * A client for streaming Server Sent Event streams.
 *
 * @author Graeme Rocher
 * @since 1.0
 */
public interface SseClient {

    /**
     * 

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

*

*

The downstream {@link org.reactivestreams.Subscriber} can regulate demand via the subscription

* * @param request The {@link HttpRequest} to execute * @param The request body type * @return A {@link Publisher} that emits an {@link Event} with the data represented as a {@link ByteBuffer} */ Publisher>> eventStream(HttpRequest request); /** *

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

*

*

The downstream {@link org.reactivestreams.Subscriber} can regulate demand via the subscription

* * @param request The {@link HttpRequest} to execute * @param eventType The event data type * @param The request body type * @param The event body type * @return A {@link Publisher} that emits an {@link Event} with the data represented by the eventType argument */ Publisher> eventStream(HttpRequest request, Argument eventType); /** *

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

*

*

The downstream {@link org.reactivestreams.Subscriber} can regulate demand via the subscription

* * @param request The {@link HttpRequest} to execute * @param eventType The event data type * @param The request body type * @param The event body type * @return A {@link Publisher} that emits an {@link Event} with the data represented by the eventType argument */ default Publisher> eventStream(HttpRequest request, Class eventType) { return eventStream(request, Argument.of(eventType)); } /** *

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

*

*

The downstream {@link org.reactivestreams.Subscriber} can regulate demand via the subscription

* * @param uri The request URI * @param eventType The event data type * @param The event body type * @return A {@link Publisher} that emits an {@link Event} with the data represented by the eventType argument */ default Publisher> eventStream(String uri, Class eventType) { return eventStream(HttpRequest.GET(uri), Argument.of(eventType)); } /** *

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

*

*

The downstream {@link org.reactivestreams.Subscriber} can regulate demand via the subscription

* * @param uri The request URI * @param eventType The event data type * @param The event body type * @return A {@link Publisher} that emits an {@link Event} with the data represented by the eventType argument */ default Publisher> eventStream(String uri, Argument eventType) { return eventStream(HttpRequest.GET(uri), eventType); } }