org.zodiac.actuate.application.maintenance.AppReadinessMaintenanceOperator Maven / Gradle / Ivy
package org.zodiac.actuate.application.maintenance;
import org.springframework.web.bind.annotation.RequestMethod;
import org.zodiac.core.application.availability.AppAvailability;
import org.zodiac.core.application.availability.ReadinessState;
import org.zodiac.sdk.toolkit.util.lang.StrUtil;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class AppReadinessMaintenanceOperator implements AppMaintenanceOperator {
private static final String STATE_KEY = "state";
private AppAvailability availability;
private final List supportedMethods;
public AppReadinessMaintenanceOperator(AppAvailability availability) {
this.availability = availability;
supportedMethods = Arrays.asList(RequestMethod.DELETE, RequestMethod.POST, RequestMethod.PUT);
}
@Override
public String getOperatorName() {
return "app-readiness";
}
@Override
public void process(Map params) {
String expect = params.get(STATE_KEY);
if (StrUtil.isNotEmpty(expect) && StrUtil.notEqualsCharSeq(expect, this.availability.getReadinessState().getDesc())) {
ReadinessState state = ReadinessState.forDesc(expect);
this.availability.setReadinessState(state);
}
}
@Override
public Object getStatus() {
return null;
}
@Override
public List supportedMethods() {
return supportedMethods;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy