{"action":"created","issue":{"url":"https://api.github.com/repos/jupyter/jupyter-js-services/issues/21","labels_url":"https://api.github.com/repos/jupyter/jupyter-js-services/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/jupyter/jupyter-js-services/issues/21/comments","events_url":"https://api.github.com/repos/jupyter/jupyter-js-services/issues/21/events","html_url":"https://github.com/jupyter/jupyter-js-services/pull/21","id":103876593,"number":21,"title":"DO NOT MERGE - Discussion Only - Kernel Interface","user":{"login":"sccolbert","id":137289,"avatar_url":"https://avatars.githubusercontent.com/u/137289?v=3","gravatar_id":"","url":"https://api.github.com/users/sccolbert","html_url":"https://github.com/sccolbert","followers_url":"https://api.github.com/users/sccolbert/followers","following_url":"https://api.github.com/users/sccolbert/following{/other_user}","gists_url":"https://api.github.com/users/sccolbert/gists{/gist_id}","starred_url":"https://api.github.com/users/sccolbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sccolbert/subscriptions","organizations_url":"https://api.github.com/users/sccolbert/orgs","repos_url":"https://api.github.com/users/sccolbert/repos","events_url":"https://api.github.com/users/sccolbert/events{/privacy}","received_events_url":"https://api.github.com/users/sccolbert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-08-29T20:11:29Z","updated_at":"2015-08-30T19:03:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jupyter/jupyter-js-services/pulls/21","html_url":"https://github.com/jupyter/jupyter-js-services/pull/21","diff_url":"https://github.com/jupyter/jupyter-js-services/pull/21.diff","patch_url":"https://github.com/jupyter/jupyter-js-services/pull/21.patch"},"body":"Pinging @minrk @blink1073 \r\n\r\nHey guys. I was looking through the kernel services code, and am still not too happy with the status quo. I think there is a large conflation of responsibilities between ajax calls and websockets, which ends up muddling state and lifetime management, and generally making the code difficult to follow.\r\n\r\nIn this PR I've stubbed out two files with just interfaces and functions: `kernel.ts` and `kernelhelpers.ts`. Ignore the diffs, and just look at those two files.\r\n\r\nhttps://github.com/sccolbert/jupyter-js-services/blob/kernel-interface/src/kernel.ts\r\nhttps://github.com/sccolbert/jupyter-js-services/blob/kernel-interface/src/kernelhelpers.ts\r\n\r\nMy idea is to make the kernel \"object\" pretty dumb and to have deal only with the websocket communication. I view the REST API as \"external\" kernel management, so those are expressed as external functions which either operate on kernel ids, or create IKernel objects as appropriate. I think this provides a nice mental separation of responsibilities, and it will allow for a much clear implementation of the web socket management, since it's isolated from all the other stuff.\r\n\r\nIn addition, the IKernel interface its kept extremely simple. It expose name, id, and status (read only), and a sendMessage method which takes a well-formed kernel message. We can then have a suite of functions in `kernelhelpers.ts` which assemble and all the various messages supported by the message spec. Having these as separate functions keeps the IKernel implementation small and easy to understand and test, and allows that library of helpers to expand and grow without require modifications to the kernel implementation. It also opens the door for alternative IKernel implementations, should we ever need it. Finally, it allows each function to expose an interface which makes the most sense for that particular message. For most messages, the kernel future object can be consumed internally to the function and converted into a promise result, making it much easier to use.\r\n\r\nWe could also follow a similar pattern for sessions, which would fully remove the current confusion around the various start/stop/restart/connect/disconnect methods which exist on kernel, and who should use which and when.\r\n\r\nWhat do you all think about this? I much prefer this approach as I think it clearly separates concerns, and makes the code more approachable.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/jupyter/jupyter-js-services/issues/comments/136175244","html_url":"https://github.com/jupyter/jupyter-js-services/pull/21#issuecomment-136175244","issue_url":"https://api.github.com/repos/jupyter/jupyter-js-services/issues/21","id":136175244,"user":{"login":"sccolbert","id":137289,"avatar_url":"https://avatars.githubusercontent.com/u/137289?v=3","gravatar_id":"","url":"https://api.github.com/users/sccolbert","html_url":"https://github.com/sccolbert","followers_url":"https://api.github.com/users/sccolbert/followers","following_url":"https://api.github.com/users/sccolbert/following{/other_user}","gists_url":"https://api.github.com/users/sccolbert/gists{/gist_id}","starred_url":"https://api.github.com/users/sccolbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sccolbert/subscriptions","organizations_url":"https://api.github.com/users/sccolbert/orgs","repos_url":"https://api.github.com/users/sccolbert/repos","events_url":"https://api.github.com/users/sccolbert/events{/privacy}","received_events_url":"https://api.github.com/users/sccolbert/received_events","type":"User","site_admin":false},"created_at":"2015-08-30T19:03:30Z","updated_at":"2015-08-30T19:03:30Z","body":"@minrk will you be around tomorrow for chat about this?"}}