Skip to content

Commit ffe8799

Browse files
Merge pull request #247 from wttech/skip-by-extension
Skip by extension
2 parents 75a6877 + 533fa83 commit ffe8799

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

core/src/main/java/dev/vml/es/acm/core/code/ExecutionContext.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static String varPath(String executionId) {
3636

3737
private boolean debug = false;
3838

39-
private boolean locking = true;
39+
private boolean skipped = false;
4040

4141
private final Inputs inputs;
4242

@@ -143,12 +143,12 @@ public void setDebug(boolean debug) {
143143
this.debug = debug;
144144
}
145145

146-
public boolean isLocking() {
147-
return locking;
146+
public boolean isSkipped() {
147+
return skipped;
148148
}
149149

150-
public void setLocking(boolean locking) {
151-
this.locking = locking;
150+
public void setSkipped(boolean skipped) {
151+
this.skipped = skipped;
152152
}
153153

154154
public Inputs getInputs() {

core/src/main/java/dev/vml/es/acm/core/code/ExecutionId.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
public final class ExecutionId {
88

9+
public static final String HEALTH_CHECK = "health-check";
10+
911
private ExecutionId() {
1012
// intentionally empty
1113
}

core/src/main/java/dev/vml/es/acm/core/code/Executor.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ public Execution execute(ExecutionContext context) throws AcmException {
183183
private ContextualExecution executeInternal(ExecutionContext context) {
184184
ContextualExecution.Builder execution = new ContextualExecution.Builder(context).start();
185185

186+
boolean healthChecking = ExecutionId.HEALTH_CHECK.equals(context.getId());
187+
if ((!healthChecking && context.isSkipped())) {
188+
return execution.end(ExecutionStatus.SKIPPED);
189+
}
190+
186191
try {
187192
statuses.put(context.getId(), ExecutionStatus.PARSING);
188193

@@ -204,13 +209,14 @@ private ContextualExecution executeInternal(ExecutionContext context) {
204209
return execution.end(ExecutionStatus.SUCCEEDED);
205210
}
206211

212+
boolean locking = !healthChecking;
207213
String lockName = executableLockName(context);
208-
if (context.isLocking() && queryLocker(resolverFactory, l -> l.isLocked(lockName))) {
214+
if (locking && queryLocker(resolverFactory, l -> l.isLocked(lockName))) {
209215
return execution.end(ExecutionStatus.SKIPPED);
210216
}
211217

212218
try {
213-
if (context.isLocking()) {
219+
if (locking) {
214220
useLocker(resolverFactory, l -> l.lock(lockName));
215221
}
216222
statuses.put(context.getId(), ExecutionStatus.RUNNING);
@@ -222,7 +228,7 @@ private ContextualExecution executeInternal(ExecutionContext context) {
222228
contentScript.run();
223229
return execution.end(ExecutionStatus.SUCCEEDED);
224230
} finally {
225-
if (context.isLocking()) {
231+
if (locking) {
226232
useLocker(resolverFactory, l -> l.unlock(lockName));
227233
}
228234
}

core/src/main/java/dev/vml/es/acm/core/instance/HealthChecker.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,14 @@ private void checkComponents(List<HealthIssue> issues) {
243243

244244
private void checkCodeExecutor(List<HealthIssue> issues, ResourceResolver resourceResolver) {
245245
try (ExecutionContext context = executor.createContext(
246-
ExecutionId.generate(),
246+
ExecutionId.HEALTH_CHECK,
247247
resourceResolver.getUserID(),
248248
ExecutionMode.RUN,
249249
Code.consoleMinimal(),
250250
new InputValues(),
251251
resourceResolver,
252252
new CodeOutputMemory())) {
253253
context.setHistory(false);
254-
context.setLocking(false);
255254

256255
Execution execution = executor.execute(context);
257256
if (execution.getStatus() != ExecutionStatus.SUCCEEDED) {

0 commit comments

Comments
 (0)