Skip to content

Commit

Permalink
finish migration to the multi service per path model
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterjackson committed Dec 20, 2023
1 parent a9928e7 commit c9e81e0
Show file tree
Hide file tree
Showing 5 changed files with 459 additions and 628 deletions.
17 changes: 0 additions & 17 deletions src/main/java/com/meta/cp4m/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@
import com.meta.cp4m.message.MessageHandler;
import com.meta.cp4m.message.RequestProcessor;
import com.meta.cp4m.message.ThreadState;
import com.meta.cp4m.routing.Acceptor;
import com.meta.cp4m.routing.Handler;
import com.meta.cp4m.routing.Route;
import com.meta.cp4m.store.ChatStore;
import io.javalin.Javalin;
import io.javalin.http.Context;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -46,15 +42,6 @@ public Service(
this.path = path;
}

void handle(Context ctx) {
List<T> messages = handler.processRequest(ctx);
// TODO: once we have a non-volatile store, on startup send stored but not replied to messages
for (T m : messages) {
ThreadState<T> thread = store.add(m);
executorService.submit(() -> execute(thread));
}
}

<IN> void handler(Context ctx, IN in, RequestProcessor<IN, T> processor) {
List<T> messages = null;
try {
Expand All @@ -74,10 +61,6 @@ <IN> void handler(Context ctx, IN in, RequestProcessor<IN, T> processor) {
}
}

public void register(Javalin app) {
handler.handlers().forEach(m -> app.addHandler(m, path, this::handle));
}

public String path() {
return path;
}
Expand Down
Loading

0 comments on commit c9e81e0

Please sign in to comment.