Package io.datareplication.consumer.feed
Class FeedConsumer.Builder
- java.lang.Object
-
- io.datareplication.consumer.feed.FeedConsumer.Builder
-
- Enclosing interface:
- FeedConsumer
public static class FeedConsumer.Builder extends java.lang.Object
A builder forFeedConsumer
.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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FeedConsumer.Builder
additionalHeaders(@NonNull HttpHeader... headers)
Add the given headers to every HTTP request made by this consumer.FeedConsumer.Builder
authorization(@NonNull Authorization authorization)
Use the givenAuthorization
for every HTTP request made by this consumer.FeedConsumer.Builder
authorization(@NonNull java.util.function.Supplier<@NonNull Authorization> authorizationSupplier)
Use the given function to get theAuthorization
to use for HTTP requests made by this consumer.@NonNull FeedConsumer
build()
Build a newFeedConsumer
with the parameters set on this 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 givenAuthorization
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
-
build
@NonNull public @NonNull FeedConsumer build()
Build a newFeedConsumer
with the parameters set on this builder.- Returns:
- a new
FeedConsumer
-
-