Tabnine Logo
Eventual.from
Code IndexAdd Tabnine to your IDE (free)

How to use
from
method
in
com.hotels.styx.api.Eventual

Best Java code snippets using com.hotels.styx.api.Eventual.from (Showing top 6 results out of 315)

origin: HotelsDotCom/styx

@Override
public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) {
  return chain.proceed(request)
      .flatMap(response -> Eventual.from(processAsynchronously(response, config.delayMillis())));
}
origin: HotelsDotCom/styx

/**
 * Aggregates content stream and converts this request to a {@link HttpRequest}.
 * <p>
 * Returns a {@link Eventual} that eventually produces a
 * {@link HttpRequest}. The resulting full request object has the same
 * request line, headers, and content as this request.
 * <p>
 * The content stream is aggregated asynchronously. The stream may be connected
 * to a network socket or some other content producer. Once aggregated, a
 * HttpRequest object is emitted on the returned {@link Eventual}.
 * <p>
 * A sole {@code maxContentBytes} argument is a backstop defence against excessively
 * long content streams. The {@code maxContentBytes} should be set to a sensible
 * value according to your application requirements and heap size. When the content
 * size stream exceeds the {@code maxContentBytes}, a @{link ContentOverflowException}
 * is emitted on the returned observable.
 *
 * @param maxContentBytes maximum expected content size
 * @return a {@link Eventual}
 */
public Eventual<HttpRequest> aggregate(int maxContentBytes) {
  return Eventual.from(
      body.aggregate(maxContentBytes)
        .thenApply(it -> new HttpRequest.Builder(this, decodeAndRelease(it)).build())
  );
}
origin: HotelsDotCom/styx

@Test
public void createFromCompletionStage() {
  CompletableFuture<String> future = new CompletableFuture<>();
  Eventual<String> eventual = Eventual.from(future);
  StepVerifier.create(eventual)
      .thenRequest(1)
      .expectNextCount(0)
      .then(() -> future.complete("hello"))
      .expectNext("hello")
      .verifyComplete();
}
origin: HotelsDotCom/styx

@Override
public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) {
  return chain.proceed(request)
      .flatMap(response ->  response.aggregate(this.maxContentLength))
      .flatMap(fullResponse -> Eventual.from(asyncEvent(this.delayMillis))
          .map(x -> fullResponse))
      .map(HttpResponse::stream);
}
origin: HotelsDotCom/styx

/**
 * Aggregates content stream and converts this response to a {@link HttpResponse}.
 * <p>
 * Returns a {@link Eventual <HttpResponse>} that eventually produces a
 * {@link HttpResponse}. The resulting full response object has the same
 * response line, headers, and content as this response.
 * <p>
 * The content stream is aggregated asynchronously. The stream may be connected
 * to a network socket or some other content producer. Once aggregated, a
 * HttpResponse object is emitted on the returned {@link Eventual}.
 * <p>
 * A sole {@code maxContentBytes} argument is a backstop defence against excessively
 * long content streams. The {@code maxContentBytes} should be set to a sensible
 * value according to your application requirements and heap size. When the content
 * size stream exceeds the {@code maxContentBytes}, a @{link ContentOverflowException}
 * is emitted on the returned observable.
 *
 * @param maxContentBytes maximum expected content size
 * @return a {@link Eventual}
 */
public Eventual<HttpResponse> aggregate(int maxContentBytes) {
  return Eventual.from(body.aggregate(maxContentBytes))
      .map(it -> new HttpResponse.Builder(this, decodeAndRelease(it))
        .disableValidation()
        .build()
      );
}
origin: HotelsDotCom/styx

  @Override
  public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) {
    return request.aggregate(config.maxContentLength())
            .flatMap(fullHttpRequest -> Eventual.from(asyncOperation(config.delayMillis())))
            .map(outcome -> request.newBuilder().header("X-Outcome", outcome.result()))
            .flatMap(x -> chain.proceed(request));
  }
}
com.hotels.styx.apiEventualfrom

Javadoc

Creates a new Eventual from a CompletionStage.

Popular methods of Eventual

  • of
    Creates a new Eventual object from given value.
  • map
    Transforms an element synchronously by applying a mapping function.
  • <init>
    Constructs a new Eventual object from an reactive streams Publisher.
  • flatMap
    Transform an element asynchronously by applying a mapping function.
  • error
    Creates a new (@link Eventual} that emits an error.
  • onError
    Transforms an error by applying an error handler function.
  • fromMono

Popular in Java

  • Reading from database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSharedPreferences (Context)
  • setRequestProperty (URLConnection)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Permission (java.security)
    Legacy security code; do not use.
  • Reference (javax.naming)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now