kwik icon indicating copy to clipboard operation
kwik copied to clipboard

ServerConnector.shutdown?

Open zhkl0228 opened this issue 1 year ago • 2 comments

After a ServerConnector instance is started, how to shut down the instance?

zhkl0228 avatar Jul 04 '24 09:07 zhkl0228

Agree we need a shutdown method on ServerConnector.

ptrd avatar Jul 04 '24 10:07 ptrd

To add, would be nice if it implemented AutoCloseable

In my case, helps integration as a bean with DI framework, maybe its nice to be able to close a ServerConnector with try-with-resources as follows:

try (ServerConnector connector = ServerConnector.builder()
        ...
        .build()) {
    connector.registerApplicationProtocol(...);
    connector.start();
    
    // perform operation that interfaces with connector.
    // when scope is exit, server is gone
}

and implementation is just to make shutdown method in impl, as void close() throws Exception;, and have ServerConnector extend AutoCloseable.

mechite avatar Sep 19 '24 02:09 mechite

Implemented in release 0.9.1

ptrd avatar Nov 14 '24 17:11 ptrd