Skip to content

Commit 7bb9d99

Browse files
authored
Merge pull request #8 from Together-Java/feature/multi-snippets
Feature/multi snippets
2 parents 9a40356 + 2260643 commit 7bb9d99

38 files changed

Lines changed: 856 additions & 507 deletions

JShellAPI/RunDocker.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker run --rm -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock --name jshellapi togetherjava.org:5001/togetherjava/jshellbackend:master

JShellAPI/RunDocker.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker run --rm -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock --name jshellapi togetherjava.org:5001/togetherjava/jshellbackend:master
-58.4 KB
Binary file not shown.

JShellAPI/gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 5 deletions
This file was deleted.

JShellAPI/src/main/java/org/togetherjava/jshellapi/Config.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public record Config(
77
long regularSessionTimeoutSeconds,
88
long oneTimeSessionTimeoutSeconds,
99
long evalTimeoutSeconds,
10+
int sysOutCharLimit,
1011
long maxAliveSessions,
1112
int dockerMaxRamMegaBytes,
1213
double dockerCPUsUsage,
@@ -15,6 +16,7 @@ public record Config(
1516
if(regularSessionTimeoutSeconds <= 0) throw new RuntimeException("Invalid value " + regularSessionTimeoutSeconds);
1617
if(oneTimeSessionTimeoutSeconds <= 0) throw new RuntimeException("Invalid value " + oneTimeSessionTimeoutSeconds);
1718
if(evalTimeoutSeconds <= 0) throw new RuntimeException("Invalid value " + evalTimeoutSeconds);
19+
if(sysOutCharLimit <= 0) throw new RuntimeException("Invalid value " + sysOutCharLimit);
1820
if(maxAliveSessions <= 0) throw new RuntimeException("Invalid value " + maxAliveSessions);
1921
if(dockerMaxRamMegaBytes <= 0) throw new RuntimeException("Invalid value " + dockerMaxRamMegaBytes);
2022
if(dockerCPUsUsage <= 0) throw new RuntimeException("Invalid value " + dockerCPUsUsage);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.togetherjava.jshellapi.dto;
2+
3+
public record JShellEvalAbortion(String sourceCause, String remainingSource, JShellEvalAbortionCause cause) {
4+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.togetherjava.jshellapi.dto;
2+
3+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
4+
import com.fasterxml.jackson.annotation.JsonTypeName;
5+
6+
import java.util.List;
7+
8+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
9+
public sealed interface JShellEvalAbortionCause {
10+
11+
@JsonTypeName("TIMEOUT")
12+
record TimeoutAbortionCause() implements JShellEvalAbortionCause {
13+
}
14+
15+
@JsonTypeName("UNCAUGHT_EXCEPTION")
16+
record UnhandledExceptionAbortionCause(String exceptionClass, String exceptionMessage) implements JShellEvalAbortionCause {
17+
}
18+
19+
@JsonTypeName("COMPILE_TIME_ERROR")
20+
record CompileTimeErrorAbortionCause(List<String> errors) implements JShellEvalAbortionCause {
21+
}
22+
23+
@JsonTypeName("SYNTAX_ERROR")
24+
record SyntaxErrorAbortionCause() implements JShellEvalAbortionCause {
25+
}
26+
}

JShellAPI/src/main/java/org/togetherjava/jshellapi/dto/JShellExceptionResult.java

Lines changed: 0 additions & 4 deletions
This file was deleted.

JShellAPI/src/main/java/org/togetherjava/jshellapi/dto/JShellResult.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,11 @@
55
import java.util.List;
66

77
public record JShellResult(
8-
SnippetStatus status,
9-
SnippetType type,
10-
int id,
11-
String source,
12-
@Nullable
13-
String result,
14-
@Nullable
15-
JShellExceptionResult exception,
8+
List<JShellSnippetResult> snippetsResults,
9+
@Nullable JShellEvalAbortion abortion,
1610
boolean stdoutOverflow,
17-
String stdout,
18-
List<String> errors) {
11+
String stdout) {
1912
public JShellResult {
20-
errors = List.copyOf(errors);
13+
snippetsResults = List.copyOf(snippetsResults);
2114
}
2215
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.togetherjava.jshellapi.dto;
2+
3+
import org.springframework.lang.Nullable;
4+
5+
public record JShellSnippetResult(
6+
SnippetStatus status,
7+
SnippetType type,
8+
int id,
9+
String source,
10+
@Nullable
11+
String result) {
12+
}

0 commit comments

Comments
 (0)