karaf icon indicating copy to clipboard operation
karaf copied to clipboard

KARAF-7174: Implement a SSH channel resource cleaner whiteboard

Open jbonofre opened this issue 1 year ago • 6 comments

jbonofre avatar Nov 12 '24 15:11 jbonofre

This is a great idea and useful feature. Esp for other commands that use connection pools, or other stateful resources.

One suggestion -- perhaps a rename for consistency?

CommandCloseListener?

mattrpav avatar Nov 12 '24 18:11 mattrpav

Yes, Good point about the name. My only comment is that (potentially) it could be used for other services than commands. But let's start with shell commands :)

jbonofre avatar Nov 12 '24 20:11 jbonofre

Yes, Good point about the name. My only comment is that (potentially) it could be used for other services than commands. But let's start with shell commands :)

How do you see it working for other services? I think things like scr services should use deactivate(). I'm struggling to find a use case where another service would go 'out-of-scope' so to speak similar to how the shell command can timeout.

mattrpav avatar Nov 12 '24 20:11 mattrpav

@mattrpav I see a use case: a command use a service which starts a thread. The service has to be hook with ssh session to stop the thread when the session disconnects. So the service is not a shell command but it has to clean resources sync with ssh session. SCR deactivate is a hook on SCR component lifecycle not the ssh session.

jbonofre avatar Nov 13 '24 06:11 jbonofre

@mattrpav I see a use case: a command use a service which starts a thread. The service has to be hook with ssh session to stop the thread when the session disconnects. So the service is not a shell command but it has to clean resources sync with ssh session. SCR deactivate is a hook on SCR component lifecycle not the ssh session.

What about simply having Commands implement the JDK's built-in Closable interface and follow a convention vs marking the command with a domain-specific interface?

Seems like (commandInstance instanceof Closeable) would do the trick and we wouldn't need to create a new interface. Thoughts?

mattrpav avatar Nov 13 '24 16:11 mattrpav

@mattrpav that's a good idea to leverage Closeable. Let me do an experiment.

jbonofre avatar Nov 13 '24 16:11 jbonofre