refactor(server): Fi StdioServerTransportProvider initialization flow (#74)
Extract message processing initialization from StdioMcpSessionTransport constructor into a separate initProcessing() method. Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
parent
d7177f15a3
commit
96e6d9cc15
1 changed files with 9 additions and 5 deletions
|
|
@ -93,7 +93,9 @@ public class StdioServerTransportProvider implements McpServerTransportProvider
|
||||||
@Override
|
@Override
|
||||||
public void setSessionFactory(McpServerSession.Factory sessionFactory) {
|
public void setSessionFactory(McpServerSession.Factory sessionFactory) {
|
||||||
// Create a single session for the stdio connection
|
// Create a single session for the stdio connection
|
||||||
this.session = sessionFactory.create(new StdioMcpSessionTransport());
|
var transport = new StdioMcpSessionTransport();
|
||||||
|
this.session = sessionFactory.create(transport);
|
||||||
|
transport.initProcessing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -142,10 +144,6 @@ public class StdioServerTransportProvider implements McpServerTransportProvider
|
||||||
"stdio-inbound");
|
"stdio-inbound");
|
||||||
this.outboundScheduler = Schedulers.fromExecutorService(Executors.newSingleThreadExecutor(),
|
this.outboundScheduler = Schedulers.fromExecutorService(Executors.newSingleThreadExecutor(),
|
||||||
"stdio-outbound");
|
"stdio-outbound");
|
||||||
|
|
||||||
handleIncomingMessages();
|
|
||||||
startInboundProcessing();
|
|
||||||
startOutboundProcessing();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -181,6 +179,12 @@ public class StdioServerTransportProvider implements McpServerTransportProvider
|
||||||
logger.debug("Session transport closed");
|
logger.debug("Session transport closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initProcessing() {
|
||||||
|
handleIncomingMessages();
|
||||||
|
startInboundProcessing();
|
||||||
|
startOutboundProcessing();
|
||||||
|
}
|
||||||
|
|
||||||
private void handleIncomingMessages() {
|
private void handleIncomingMessages() {
|
||||||
this.inboundSink.asFlux().flatMap(message -> session.handle(message)).doOnTerminate(() -> {
|
this.inboundSink.asFlux().flatMap(message -> session.handle(message)).doOnTerminate(() -> {
|
||||||
// The outbound processing will dispose its scheduler upon completion
|
// The outbound processing will dispose its scheduler upon completion
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue