Package org.forgerock.http.protocol
Class MdcAwareConsumer<T>
- java.lang.Object
-
- org.forgerock.http.protocol.MdcAwareConsumer<T>
-
- Type Parameters:
T
- the value type
- All Implemented Interfaces:
io.reactivex.rxjava3.functions.Consumer<T>
public final class MdcAwareConsumer<T> extends Object implements io.reactivex.rxjava3.functions.Consumer<T>
An implementation ofConsumer
that will preserve the SLF4J MDC.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(T t)
static <T> io.reactivex.rxjava3.functions.Consumer<T>
mdcAwareConsumer(io.reactivex.rxjava3.functions.Consumer<T> delegate)
Wraps the delegateConsumer
with anotherConsumer
instance that will capture the currentMDC
context, and will use it when delegating the calls to the delegatedConsumer
.static <T> io.reactivex.rxjava3.functions.Consumer<T>
mdcAwareConsumer(Map<String,String> mdc, io.reactivex.rxjava3.functions.Consumer<T> delegate)
Wraps the delegateConsumer
with anotherConsumer
instance that will use the providedMDC
context when delegating the calls to the delegatedConsumer
.
-
-
-
Method Detail
-
mdcAwareConsumer
public static <T> io.reactivex.rxjava3.functions.Consumer<T> mdcAwareConsumer(io.reactivex.rxjava3.functions.Consumer<T> delegate)
Wraps the delegateConsumer
with anotherConsumer
instance that will capture the currentMDC
context, and will use it when delegating the calls to the delegatedConsumer
.- Type Parameters:
T
- the value type.- Parameters:
delegate
- the Subscriber to delegate the calls to- Returns:
- A
Consumer
that will position the capturedMDC
context before each call. - See Also:
mdcAwareConsumer(Consumer)
-
mdcAwareConsumer
public static <T> io.reactivex.rxjava3.functions.Consumer<T> mdcAwareConsumer(Map<String,String> mdc, io.reactivex.rxjava3.functions.Consumer<T> delegate)
Wraps the delegateConsumer
with anotherConsumer
instance that will use the providedMDC
context when delegating the calls to the delegatedConsumer
.- Type Parameters:
T
- the value type.- Parameters:
mdc
- TheMDC
to use when delegating the callsdelegate
- the Consumer to delegate the calls to- Returns:
- A
Consumer
that will position the capturedMDC
context before each call.
-
-