Class FeedConsumer.Builder

  • Enclosing interface:
    FeedConsumer

    public static class FeedConsumer.Builder
    extends java.lang.Object
    A builder for FeedConsumer.

    Each of the builder methods modifies the state of the builder and returns the same instance. Because of that, builders are not thread-safe.

    See Also:
    FeedConsumer.builder()
    • Method Detail

      • additionalHeaders

        @NonNull
        public FeedConsumer.Builder additionalHeaders​(@NonNull
                                                      @NonNull HttpHeader... headers)
        Add the given headers to every HTTP request made by this consumer. Calling this method multiple times will add all the headers from all calls.
        Parameters:
        headers - headers to add to every HTTP request
        Returns:
        this builder
      • authorization

        @NonNull
        public FeedConsumer.Builder authorization​(@NonNull
                                                  @NonNull Authorization authorization)
        Use the given Authorization for every HTTP request made by this consumer.
        Parameters:
        authorization - the Authorization to use for HTTP requests
        Returns:
        this builder
      • authorization

        @NonNull
        public FeedConsumer.Builder authorization​(@NonNull
                                                  @NonNull java.util.function.Supplier<@NonNull Authorization> authorizationSupplier)

        Use the given function to get the Authorization to use for HTTP requests made by this consumer. The function is called once for each request.

        The given function is expected to return quickly to avoid holding up requests. Because of that, the function should not perform any network requests. If your service requires a fresh authentication token periodically, the recommended approach is to perform the refresh out-of-band (e.g. on a separate thread with a timer) and write the new token to a shared memory location that the supplier function then reads from.

        Parameters:
        authorizationSupplier - a function returning the Authorization to use for HTTP requests
        Returns:
        this builder