Skip to content

Commit

Permalink
MdcHelper, MdcHelperTest needn't be public
Browse files Browse the repository at this point in the history
The MdcHelper methods are only meant to be called within the Stairway implementation package.
  • Loading branch information
okotsopoulos committed Feb 29, 2024
1 parent 6668262 commit 4ac56fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions stairway/src/main/java/bio/terra/stairway/impl/MdcHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
import org.slf4j.MDC;

/**
* Utility methods to make Stairway flight runnables context-aware, using mapped diagnostic context (MDC).
* Utility methods to make Stairway flight runnables context-aware, using mapped diagnostic context
* (MDC).
*/
public class MdcHelper {
class MdcHelper {

/** ID of the flight */
public static final String FLIGHT_ID_KEY = "flightId";
static final String FLIGHT_ID_KEY = "flightId";

/** Class of the flight */
public static final String FLIGHT_CLASS_KEY = "flightClass";
static final String FLIGHT_CLASS_KEY = "flightClass";

/** Class of the flight step */
public static final String FLIGHT_STEP_CLASS_KEY = "flightStepClass";
static final String FLIGHT_STEP_CLASS_KEY = "flightStepClass";

/** Direction of the step (START, DO, SWITCH, or UNDO) */
public static final String FLIGHT_STEP_DIRECTION_KEY = "flightStepDirection";
static final String FLIGHT_STEP_DIRECTION_KEY = "flightStepDirection";

/** The step's execution order */
public static final String FLIGHT_STEP_NUMBER_KEY = "flightStepNumber";
static final String FLIGHT_STEP_NUMBER_KEY = "flightStepNumber";

/**
* @return the flightRunner modified to propagate the MDC from the calling thread and
* flight-specific context to the child thread spawned to run the flight.
*/
public static Runnable withMdcAndFlightContext(
Runnable flightRunner, FlightContext flightContext) {
static Runnable withMdcAndFlightContext(Runnable flightRunner, FlightContext flightContext) {
// Save the calling thread's context
Map<String, String> contextMap = MDC.getCopyOfContextMap();
return () -> {
Expand Down Expand Up @@ -66,11 +66,11 @@ private static Map<String, String> stepContextForMdc(FlightContext context) {
FLIGHT_STEP_NUMBER_KEY, Integer.toString(context.getStepIndex()));
}

public static void addStepContextToMdc(FlightContext context) {
static void addStepContextToMdc(FlightContext context) {
stepContextForMdc(context).forEach(MDC::put);
}

public static void removeStepContextFromMdc(FlightContext context) {
static void removeStepContextFromMdc(FlightContext context) {
stepContextForMdc(context).keySet().forEach(MDC::remove);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.slf4j.MDC;

@Tag("unit")
public class MdcHelperTest {
class MdcHelperTest {
private static final Map<String, String> FOO_BAR = Map.of("foo", "bar");
private static final String FLIGHT_ID = "flightId" + UUID.randomUUID();
private static final String FLIGHT_CLASS = "flightClass" + UUID.randomUUID();
Expand Down

0 comments on commit 4ac56fa

Please sign in to comment.