{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/kibana/pulls/comments/227060011","pull_request_review_id":167015985,"id":227060011,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzA2MDAxMQ==","diff_hunk":"@@ -5,56 +5,56 @@\n  */\n \n import socket from 'socket.io';\n-import { createHandlers } from '../lib/create_handlers';\n-import { socketInterpreterProvider } from '../../common/interpreter/socket_interpret';\n import { serializeProvider } from '../../common/lib/serialize';\n import { functionsRegistry } from '../../common/lib/functions_registry';\n import { typesRegistry } from '../../common/lib/types_registry';\n-import { loadServerPlugins } from '../lib/load_server_plugins';\n-import { getAuthHeader } from './get_auth/get_auth_header';\n+import { populateServerRegistries } from '../lib/populate_server_registries';\n+import { routeExpressionProvider } from '../lib/route_expression';\n+import { browser } from '../lib/route_expression/browser';\n+import { thread } from '../lib/route_expression/thread';\n+import { server as serverEnv } from '../lib/route_expression/server';\n+import { createError } from '../../common/interpreter/create_error';\n+\n+console.log('LOADING SOCKET, IMPORTING EXPRESSION ROUTER');\n \n export function socketApi(server) {\n   const io = socket(server.listener, { path: '/socket.io' });\n \n   io.on('connection', socket => {\n     // This is the HAPI request object\n-    const request = socket.handshake;\n \n-    const authHeader = getAuthHeader(request, server);\n+    const types = typesRegistry.toJS();\n+    const { serialize, deserialize } = serializeProvider(types);\n+\n+    // We'd be better off creating the environments here, then passing them to the expression router\n+    const routeExpression = routeExpressionProvider([\n+      thread({ onFunctionNotFound, serialize, deserialize }),\n+      serverEnv({ server, socket, onFunctionNotFound, serialize, deserialize }),","path":"x-pack/plugins/canvas/server/routes/socket.js","position":34,"original_position":34,"commit_id":"c90c4b2f6c0c4f2607a2943e73f98e15e20f94a6","original_commit_id":"c6823e9e679261bcfd082c9365b85a49e85df5ea","user":{"login":"rashidkpc","id":1250387,"node_id":"MDQ6VXNlcjEyNTAzODc=","avatar_url":"https://avatars1.githubusercontent.com/u/1250387?v=4","gravatar_id":"","url":"https://api.github.com/users/rashidkpc","html_url":"https://github.com/rashidkpc","followers_url":"https://api.github.com/users/rashidkpc/followers","following_url":"https://api.github.com/users/rashidkpc/following{/other_user}","gists_url":"https://api.github.com/users/rashidkpc/gists{/gist_id}","starred_url":"https://api.github.com/users/rashidkpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rashidkpc/subscriptions","organizations_url":"https://api.github.com/users/rashidkpc/orgs","repos_url":"https://api.github.com/users/rashidkpc/repos","events_url":"https://api.github.com/users/rashidkpc/events{/privacy}","received_events_url":"https://api.github.com/users/rashidkpc/received_events","type":"User","site_admin":false},"body":"because it needs to it build the auth headers, etc","created_at":"2018-10-22T17:17:29Z","updated_at":"2018-10-22T17:17:29Z","html_url":"https://github.com/elastic/kibana/pull/23301#discussion_r227060011","pull_request_url":"https://api.github.com/repos/elastic/kibana/pulls/23301","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/elastic/kibana/pulls/comments/227060011"},"html":{"href":"https://github.com/elastic/kibana/pull/23301#discussion_r227060011"},"pull_request":{"href":"https://api.github.com/repos/elastic/kibana/pulls/23301"}},"in_reply_to_id":226727669},"pull_request":{"url":"https://api.github.com/repos/elastic/kibana/pulls/23301","id":216458263,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2NDU4MjYz","html_url":"https://github.com/elastic/kibana/pull/23301","diff_url":"https://github.com/elastic/kibana/pull/23301.diff","patch_url":"https://github.com/elastic/kibana/pull/23301.patch","issue_url":"https://api.github.com/repos/elastic/kibana/issues/23301","number":23301,"state":"open","locked":false,"title":"Initial threading implementation","user":{"login":"rashidkpc","id":1250387,"node_id":"MDQ6VXNlcjEyNTAzODc=","avatar_url":"https://avatars1.githubusercontent.com/u/1250387?v=4","gravatar_id":"","url":"https://api.github.com/users/rashidkpc","html_url":"https://github.com/rashidkpc","followers_url":"https://api.github.com/users/rashidkpc/followers","following_url":"https://api.github.com/users/rashidkpc/following{/other_user}","gists_url":"https://api.github.com/users/rashidkpc/gists{/gist_id}","starred_url":"https://api.github.com/users/rashidkpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rashidkpc/subscriptions","organizations_url":"https://api.github.com/users/rashidkpc/orgs","repos_url":"https://api.github.com/users/rashidkpc/repos","events_url":"https://api.github.com/users/rashidkpc/events{/privacy}","received_events_url":"https://api.github.com/users/rashidkpc/received_events","type":"User","site_admin":false},"body":"This is a minimal threading implementation for Canvas. There's still a lot to be done to make this concept great, but this is a start. \r\n\r\nWhat it does:\r\n- Creates a server side abstraction on top of the interpreter\r\n- Determines where to send the expression by checking the first function to be run\r\n- Loads common functions in a separate worker thread on the server. \r\n- Routes to a single forked worker (thread), the main thread (server), or the browser (browser), in that order\r\n- Defers back to the router when a function isn't found. Fails if the function isn't found in any of the above 3 environments\r\n- Times out the worker if it takes too long, and respawns it as needed.\r\n- Simplifies the error dialog to remove the stack. \r\n\r\nWhat is does not.:\r\n- Round robin a pool of workers\r\n- Queue. If one expression in the threaded env fails then anything sent to it in the meantime will fail. The upstream environment handles managing timeouts. I think this would only make sense todo with a pool.\r\n- Client side. This doesn't implement web workers, but we could use roughly the same architecture. \r\n- Implement a specific, pluggable `worker` environment on the server. Right now it's just common functions, so plugin authors will always end up in a thread if they put their function in the common directory.\r\n\r\nWhat I don't like:\r\n- The socketProvider code. This was reused across the server & browser, but now that it's only used in the browser there's no good reason for the abstraction\r\n- The serialize/deserialize stuff feels messy. Do we really need serialization?","created_at":"2018-09-18T22:05:33Z","updated_at":"2018-10-22T17:17:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ec9d6b524dacbb56d68222d7aa977ecd900999f","assignee":null,"assignees":[],"requested_reviewers":[{"login":"w33ble","id":404731,"node_id":"MDQ6VXNlcjQwNDczMQ==","avatar_url":"https://avatars3.githubusercontent.com/u/404731?v=4","gravatar_id":"","url":"https://api.github.com/users/w33ble","html_url":"https://github.com/w33ble","followers_url":"https://api.github.com/users/w33ble/followers","following_url":"https://api.github.com/users/w33ble/following{/other_user}","gists_url":"https://api.github.com/users/w33ble/gists{/gist_id}","starred_url":"https://api.github.com/users/w33ble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/w33ble/subscriptions","organizations_url":"https://api.github.com/users/w33ble/orgs","repos_url":"https://api.github.com/users/w33ble/repos","events_url":"https://api.github.com/users/w33ble/events{/privacy}","received_events_url":"https://api.github.com/users/w33ble/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":912981985,"node_id":"MDU6TGFiZWw5MTI5ODE5ODU=","url":"https://api.github.com/repos/elastic/kibana/labels/:Canvas","name":":Canvas","color":"fef2c0","default":false},{"id":135307740,"node_id":"MDU6TGFiZWwxMzUzMDc3NDA=","url":"https://api.github.com/repos/elastic/kibana/labels/review","name":"review","color":"0052cc","default":false},{"id":912973198,"node_id":"MDU6TGFiZWw5MTI5NzMxOTg=","url":"https://api.github.com/repos/elastic/kibana/labels/v6.5.0","name":"v6.5.0","color":"ffffff","default":false},{"id":654061976,"node_id":"MDU6TGFiZWw2NTQwNjE5NzY=","url":"https://api.github.com/repos/elastic/kibana/labels/v7.0.0","name":"v7.0.0","color":"ffffff","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/elastic/kibana/pulls/23301/commits","review_comments_url":"https://api.github.com/repos/elastic/kibana/pulls/23301/comments","review_comment_url":"https://api.github.com/repos/elastic/kibana/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/kibana/issues/23301/comments","statuses_url":"https://api.github.com/repos/elastic/kibana/statuses/c90c4b2f6c0c4f2607a2943e73f98e15e20f94a6","head":{"label":"rashidkpc:canvas/thread","ref":"canvas/thread","sha":"c90c4b2f6c0c4f2607a2943e73f98e15e20f94a6","user":{"login":"rashidkpc","id":1250387,"node_id":"MDQ6VXNlcjEyNTAzODc=","avatar_url":"https://avatars1.githubusercontent.com/u/1250387?v=4","gravatar_id":"","url":"https://api.github.com/users/rashidkpc","html_url":"https://github.com/rashidkpc","followers_url":"https://api.github.com/users/rashidkpc/followers","following_url":"https://api.github.com/users/rashidkpc/following{/other_user}","gists_url":"https://api.github.com/users/rashidkpc/gists{/gist_id}","starred_url":"https://api.github.com/users/rashidkpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rashidkpc/subscriptions","organizations_url":"https://api.github.com/users/rashidkpc/orgs","repos_url":"https://api.github.com/users/rashidkpc/repos","events_url":"https://api.github.com/users/rashidkpc/events{/privacy}","received_events_url":"https://api.github.com/users/rashidkpc/received_events","type":"User","site_admin":false},"repo":{"id":9221861,"node_id":"MDEwOlJlcG9zaXRvcnk5MjIxODYx","name":"kibana","full_name":"rashidkpc/kibana","private":false,"owner":{"login":"rashidkpc","id":1250387,"node_id":"MDQ6VXNlcjEyNTAzODc=","avatar_url":"https://avatars1.githubusercontent.com/u/1250387?v=4","gravatar_id":"","url":"https://api.github.com/users/rashidkpc","html_url":"https://github.com/rashidkpc","followers_url":"https://api.github.com/users/rashidkpc/followers","following_url":"https://api.github.com/users/rashidkpc/following{/other_user}","gists_url":"https://api.github.com/users/rashidkpc/gists{/gist_id}","starred_url":"https://api.github.com/users/rashidkpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rashidkpc/subscriptions","organizations_url":"https://api.github.com/users/rashidkpc/orgs","repos_url":"https://api.github.com/users/rashidkpc/repos","events_url":"https://api.github.com/users/rashidkpc/events{/privacy}","received_events_url":"https://api.github.com/users/rashidkpc/received_events","type":"User","site_admin":false},"html_url":"https://github.com/rashidkpc/kibana","description":"Kibana 3 & beyond. You probably want elastic/kibana.","fork":true,"url":"https://api.github.com/repos/rashidkpc/kibana","forks_url":"https://api.github.com/repos/rashidkpc/kibana/forks","keys_url":"https://api.github.com/repos/rashidkpc/kibana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rashidkpc/kibana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rashidkpc/kibana/teams","hooks_url":"https://api.github.com/repos/rashidkpc/kibana/hooks","issue_events_url":"https://api.github.com/repos/rashidkpc/kibana/issues/events{/number}","events_url":"https://api.github.com/repos/rashidkpc/kibana/events","assignees_url":"https://api.github.com/repos/rashidkpc/kibana/assignees{/user}","branches_url":"https://api.github.com/repos/rashidkpc/kibana/branches{/branch}","tags_url":"https://api.github.com/repos/rashidkpc/kibana/tags","blobs_url":"https://api.github.com/repos/rashidkpc/kibana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rashidkpc/kibana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rashidkpc/kibana/git/refs{/sha}","trees_url":"https://api.github.com/repos/rashidkpc/kibana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rashidkpc/kibana/statuses/{sha}","languages_url":"https://api.github.com/repos/rashidkpc/kibana/languages","stargazers_url":"https://api.github.com/repos/rashidkpc/kibana/stargazers","contributors_url":"https://api.github.com/repos/rashidkpc/kibana/contributors","subscribers_url":"https://api.github.com/repos/rashidkpc/kibana/subscribers","subscription_url":"https://api.github.com/repos/rashidkpc/kibana/subscription","commits_url":"https://api.github.com/repos/rashidkpc/kibana/commits{/sha}","git_commits_url":"https://api.github.com/repos/rashidkpc/kibana/git/commits{/sha}","comments_url":"https://api.github.com/repos/rashidkpc/kibana/comments{/number}","issue_comment_url":"https://api.github.com/repos/rashidkpc/kibana/issues/comments{/number}","contents_url":"https://api.github.com/repos/rashidkpc/kibana/contents/{+path}","compare_url":"https://api.github.com/repos/rashidkpc/kibana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rashidkpc/kibana/merges","archive_url":"https://api.github.com/repos/rashidkpc/kibana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rashidkpc/kibana/downloads","issues_url":"https://api.github.com/repos/rashidkpc/kibana/issues{/number}","pulls_url":"https://api.github.com/repos/rashidkpc/kibana/pulls{/number}","milestones_url":"https://api.github.com/repos/rashidkpc/kibana/milestones{/number}","notifications_url":"https://api.github.com/repos/rashidkpc/kibana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rashidkpc/kibana/labels{/name}","releases_url":"https://api.github.com/repos/rashidkpc/kibana/releases{/id}","deployments_url":"https://api.github.com/repos/rashidkpc/kibana/deployments","created_at":"2013-04-04T15:56:09Z","updated_at":"2018-10-13T07:49:01Z","pushed_at":"2018-10-19T21:53:29Z","git_url":"git://github.com/rashidkpc/kibana.git","ssh_url":"git@github.com:rashidkpc/kibana.git","clone_url":"https://github.com/rashidkpc/kibana.git","svn_url":"https://github.com/rashidkpc/kibana","homepage":"","size":463414,"stargazers_count":32,"watchers_count":32,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":10,"open_issues":0,"watchers":32,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"9189c06bd0c430b99974245b21f5c8338a90e197","user":{"login":"elastic","id":6764390,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3NjQzOTA=","avatar_url":"https://avatars0.githubusercontent.com/u/6764390?v=4","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":7833168,"node_id":"MDEwOlJlcG9zaXRvcnk3ODMzMTY4","name":"kibana","full_name":"elastic/kibana","private":false,"owner":{"login":"elastic","id":6764390,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3NjQzOTA=","avatar_url":"https://avatars0.githubusercontent.com/u/6764390?v=4","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/elastic/kibana","description":":bar_chart: Kibana analytics and search dashboard for Elasticsearch","fork":false,"url":"https://api.github.com/repos/elastic/kibana","forks_url":"https://api.github.com/repos/elastic/kibana/forks","keys_url":"https://api.github.com/repos/elastic/kibana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/kibana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/kibana/teams","hooks_url":"https://api.github.com/repos/elastic/kibana/hooks","issue_events_url":"https://api.github.com/repos/elastic/kibana/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/kibana/events","assignees_url":"https://api.github.com/repos/elastic/kibana/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/kibana/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/kibana/tags","blobs_url":"https://api.github.com/repos/elastic/kibana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/kibana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/kibana/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/kibana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/kibana/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/kibana/languages","stargazers_url":"https://api.github.com/repos/elastic/kibana/stargazers","contributors_url":"https://api.github.com/repos/elastic/kibana/contributors","subscribers_url":"https://api.github.com/repos/elastic/kibana/subscribers","subscription_url":"https://api.github.com/repos/elastic/kibana/subscription","commits_url":"https://api.github.com/repos/elastic/kibana/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/kibana/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/kibana/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/kibana/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/kibana/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/kibana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/kibana/merges","archive_url":"https://api.github.com/repos/elastic/kibana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/kibana/downloads","issues_url":"https://api.github.com/repos/elastic/kibana/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/kibana/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/kibana/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/kibana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/kibana/labels{/name}","releases_url":"https://api.github.com/repos/elastic/kibana/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/kibana/deployments","created_at":"2013-01-26T04:00:59Z","updated_at":"2018-10-22T16:20:40Z","pushed_at":"2018-10-22T17:15:43Z","git_url":"git://github.com/elastic/kibana.git","ssh_url":"git@github.com:elastic/kibana.git","clone_url":"https://github.com/elastic/kibana.git","svn_url":"https://github.com/elastic/kibana","homepage":"https://www.elastic.co/products/kibana","size":552225,"stargazers_count":10297,"watchers_count":10297,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4004,"mirror_url":null,"archived":false,"open_issues_count":3640,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4004,"open_issues":3640,"watchers":10297,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/kibana/pulls/23301"},"html":{"href":"https://github.com/elastic/kibana/pull/23301"},"issue":{"href":"https://api.github.com/repos/elastic/kibana/issues/23301"},"comments":{"href":"https://api.github.com/repos/elastic/kibana/issues/23301/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/kibana/pulls/23301/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/kibana/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/kibana/pulls/23301/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/kibana/statuses/c90c4b2f6c0c4f2607a2943e73f98e15e20f94a6"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"rashidkpc"}}