Skip to content

Commit 31454bc

Browse files
committed
feat(appserver): allow injected thread mapping store
1 parent fefb73c commit 31454bc

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/main/java/io/github/easy4j/codex/appserver/CodexAppServerClient.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public class CodexAppServerClient implements AutoCloseable {
7777
private final CodexAppServerConfig config;
7878
private final ObjectMapper objectMapper =
7979
JsonMapper.builder().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).build();
80-
private final ThreadMappingCache threadBySession;
80+
private final ThreadMappingStore threadBySession;
8181
private final SessionExecutionCoordinator sessionCoordinator = new SessionExecutionCoordinator();
8282
private final Object httpClientLock = new Object();
8383
private final ExecutorService clientExecutor = Executors.newCachedThreadPool(r -> {
@@ -96,8 +96,15 @@ public class CodexAppServerClient implements AutoCloseable {
9696
* @throws NullPointerException if {@code config} is {@code null}.
9797
*/
9898
public CodexAppServerClient(CodexAppServerConfig config) {
99+
this(config, new ThreadMappingCache(
100+
Objects.requireNonNull(config, "config").getMaxSessionMappings()));
101+
}
102+
103+
public CodexAppServerClient(
104+
CodexAppServerConfig config,
105+
ThreadMappingStore threadMappingStore) {
99106
this.config = Objects.requireNonNull(config, "config");
100-
this.threadBySession = new ThreadMappingCache(config.getMaxSessionMappings());
107+
this.threadBySession = Objects.requireNonNull(threadMappingStore, "threadMappingStore");
101108
}
102109

103110
/**

0 commit comments

Comments
 (0)