{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/comments/173574332","pull_request_review_id":102793983,"id":173574332,"diff_hunk":"@@ -50,10 +50,33 @@ func (engine *WorkEngine) StartNewAsyncJob(\n \tif token == \"\" {\n \t\ttoken = engine.Token()\n \t}\n-\tgo work.Run(token, engine.topic(topic))\n+\tgo engine.start(token, work, topic)\n+\n \treturn token, nil\n }\n \n+func (engine *WorkEngine) start(token string, work Work, topic WorkTopic) {\n+\tengine.jobs[token] = make(chan JobMsg)\n+\t// run the job and close the channel in a new routine\n+\n+\tdefer func() {\n+\t\tlog.Debug(\"closing channel for job \", token, engine.jobs)\n+\t\tclose(engine.jobs[token])\n+\t\tdelete(engine.jobs, token)\n+\t}()\n+\n+\tgo func() {\n+\t\t// listen for new messages and hand them off to the subscribers\n+\t\tfor msg := range engine.jobs[token] {\n+\t\t\tfor _, sub := range engine.subscribers[topic] {\n+\t\t\t\t//TODO edge case consider the fact that a subscriber may never exit and so we would leak go routines\n+\t\t\t\tgo sub.Notify(msg)","path":"pkg/broker/work_engine.go","position":43,"original_position":43,"commit_id":"f7be0e0414cce527f659e110fa15bc292aa14d1e","original_commit_id":"f7be0e0414cce527f659e110fa15bc292aa14d1e","user":{"login":"shawn-hurley","id":1891063,"avatar_url":"https://avatars3.githubusercontent.com/u/1891063?v=4","gravatar_id":"","url":"https://api.github.com/users/shawn-hurley","html_url":"https://github.com/shawn-hurley","followers_url":"https://api.github.com/users/shawn-hurley/followers","following_url":"https://api.github.com/users/shawn-hurley/following{/other_user}","gists_url":"https://api.github.com/users/shawn-hurley/gists{/gist_id}","starred_url":"https://api.github.com/users/shawn-hurley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shawn-hurley/subscriptions","organizations_url":"https://api.github.com/users/shawn-hurley/orgs","repos_url":"https://api.github.com/users/shawn-hurley/repos","events_url":"https://api.github.com/users/shawn-hurley/events{/privacy}","received_events_url":"https://api.github.com/users/shawn-hurley/received_events","type":"User","site_admin":false},"body":"In regards to the comment, I do think that having a context timeout makes sense here. \r\n\r\nI think a simple implementation would be to wrap this in a func() that waited for a configurable amount of time. \r\n\r\nThe notify interface could then have an error return that we would log if something does go wrong. and if it returns with nil then everythng is all good. \r\n\r\n```go\r\n...\r\nfor _, sub := range engine.subscribers[topic] {\r\n         c := make(chan error, 1)\r\n        go waitForNotify(engine.duration, sub, msg)\r\n....\r\n\r\nfunc waitForNotify(d time.Duration,  w WorkSubscriber, j JobMessage) {\r\n              select {\r\n            case err := w.Notify(j):\r\n                 handle error or if nil return\r\n            case <-d:\r\n            }\r\n}\r\n\r\n```","created_at":"2018-03-09T21:36:12Z","updated_at":"2018-03-09T22:02:01Z","html_url":"https://github.com/openshift/ansible-service-broker/pull/828#discussion_r173574332","pull_request_url":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/828","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/comments/173574332"},"html":{"href":"https://github.com/openshift/ansible-service-broker/pull/828#discussion_r173574332"},"pull_request":{"href":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/828"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/828","id":174039161,"html_url":"https://github.com/openshift/ansible-service-broker/pull/828","diff_url":"https://github.com/openshift/ansible-service-broker/pull/828.diff","patch_url":"https://github.com/openshift/ansible-service-broker/pull/828.patch","issue_url":"https://api.github.com/repos/openshift/ansible-service-broker/issues/828","number":828,"state":"open","locked":false,"title":"[wip] initial changes to subscriber pattern","user":{"login":"maleck13","id":304628,"avatar_url":"https://avatars2.githubusercontent.com/u/304628?v=4","gravatar_id":"","url":"https://api.github.com/users/maleck13","html_url":"https://github.com/maleck13","followers_url":"https://api.github.com/users/maleck13/followers","following_url":"https://api.github.com/users/maleck13/following{/other_user}","gists_url":"https://api.github.com/users/maleck13/gists{/gist_id}","starred_url":"https://api.github.com/users/maleck13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maleck13/subscriptions","organizations_url":"https://api.github.com/users/maleck13/orgs","repos_url":"https://api.github.com/users/maleck13/repos","events_url":"https://api.github.com/users/maleck13/events{/privacy}","received_events_url":"https://api.github.com/users/maleck13/received_events","type":"User","site_admin":false},"body":"**Describe what this PR does and why we need it**:\r\nUpdates to how we handle the channels and subscribers based on the proposal outlined as part of \r\nhttps://github.com/openshift/ansible-service-broker/issues/638\r\n\r\n\r\n@jmrodri @eriknelson  initial WIP work here for early feedback. Not complete yet but also not miles away. Would like any feedback you have to ensure we are still on the same page and I am not heading down any rabbit holes 😄 ","created_at":"2018-03-09T15:51:08Z","updated_at":"2018-03-09T22:02:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0efc41717cddce1f6de857ae0d4a114610bde306","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":744179657,"url":"https://api.github.com/repos/openshift/ansible-service-broker/labels/do-not-merge/work-in-progress","name":"do-not-merge/work-in-progress","color":"e11d21","default":false},{"id":724844177,"url":"https://api.github.com/repos/openshift/ansible-service-broker/labels/size/XXL","name":"size/XXL","color":"ee0000","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/828/commits","review_comments_url":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/828/comments","review_comment_url":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/ansible-service-broker/issues/828/comments","statuses_url":"https://api.github.com/repos/openshift/ansible-service-broker/statuses/f7be0e0414cce527f659e110fa15bc292aa14d1e","head":{"label":"maleck13:issue-638-subcriber-improvements","ref":"issue-638-subcriber-improvements","sha":"f7be0e0414cce527f659e110fa15bc292aa14d1e","user":{"login":"maleck13","id":304628,"avatar_url":"https://avatars2.githubusercontent.com/u/304628?v=4","gravatar_id":"","url":"https://api.github.com/users/maleck13","html_url":"https://github.com/maleck13","followers_url":"https://api.github.com/users/maleck13/followers","following_url":"https://api.github.com/users/maleck13/following{/other_user}","gists_url":"https://api.github.com/users/maleck13/gists{/gist_id}","starred_url":"https://api.github.com/users/maleck13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maleck13/subscriptions","organizations_url":"https://api.github.com/users/maleck13/orgs","repos_url":"https://api.github.com/users/maleck13/repos","events_url":"https://api.github.com/users/maleck13/events{/privacy}","received_events_url":"https://api.github.com/users/maleck13/received_events","type":"User","site_admin":false},"repo":{"id":95462824,"name":"ansible-service-broker","full_name":"maleck13/ansible-service-broker","owner":{"login":"maleck13","id":304628,"avatar_url":"https://avatars2.githubusercontent.com/u/304628?v=4","gravatar_id":"","url":"https://api.github.com/users/maleck13","html_url":"https://github.com/maleck13","followers_url":"https://api.github.com/users/maleck13/followers","following_url":"https://api.github.com/users/maleck13/following{/other_user}","gists_url":"https://api.github.com/users/maleck13/gists{/gist_id}","starred_url":"https://api.github.com/users/maleck13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maleck13/subscriptions","organizations_url":"https://api.github.com/users/maleck13/orgs","repos_url":"https://api.github.com/users/maleck13/repos","events_url":"https://api.github.com/users/maleck13/events{/privacy}","received_events_url":"https://api.github.com/users/maleck13/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maleck13/ansible-service-broker","description":"Ansible Service Broker","fork":true,"url":"https://api.github.com/repos/maleck13/ansible-service-broker","forks_url":"https://api.github.com/repos/maleck13/ansible-service-broker/forks","keys_url":"https://api.github.com/repos/maleck13/ansible-service-broker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maleck13/ansible-service-broker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maleck13/ansible-service-broker/teams","hooks_url":"https://api.github.com/repos/maleck13/ansible-service-broker/hooks","issue_events_url":"https://api.github.com/repos/maleck13/ansible-service-broker/issues/events{/number}","events_url":"https://api.github.com/repos/maleck13/ansible-service-broker/events","assignees_url":"https://api.github.com/repos/maleck13/ansible-service-broker/assignees{/user}","branches_url":"https://api.github.com/repos/maleck13/ansible-service-broker/branches{/branch}","tags_url":"https://api.github.com/repos/maleck13/ansible-service-broker/tags","blobs_url":"https://api.github.com/repos/maleck13/ansible-service-broker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maleck13/ansible-service-broker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maleck13/ansible-service-broker/git/refs{/sha}","trees_url":"https://api.github.com/repos/maleck13/ansible-service-broker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maleck13/ansible-service-broker/statuses/{sha}","languages_url":"https://api.github.com/repos/maleck13/ansible-service-broker/languages","stargazers_url":"https://api.github.com/repos/maleck13/ansible-service-broker/stargazers","contributors_url":"https://api.github.com/repos/maleck13/ansible-service-broker/contributors","subscribers_url":"https://api.github.com/repos/maleck13/ansible-service-broker/subscribers","subscription_url":"https://api.github.com/repos/maleck13/ansible-service-broker/subscription","commits_url":"https://api.github.com/repos/maleck13/ansible-service-broker/commits{/sha}","git_commits_url":"https://api.github.com/repos/maleck13/ansible-service-broker/git/commits{/sha}","comments_url":"https://api.github.com/repos/maleck13/ansible-service-broker/comments{/number}","issue_comment_url":"https://api.github.com/repos/maleck13/ansible-service-broker/issues/comments{/number}","contents_url":"https://api.github.com/repos/maleck13/ansible-service-broker/contents/{+path}","compare_url":"https://api.github.com/repos/maleck13/ansible-service-broker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maleck13/ansible-service-broker/merges","archive_url":"https://api.github.com/repos/maleck13/ansible-service-broker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maleck13/ansible-service-broker/downloads","issues_url":"https://api.github.com/repos/maleck13/ansible-service-broker/issues{/number}","pulls_url":"https://api.github.com/repos/maleck13/ansible-service-broker/pulls{/number}","milestones_url":"https://api.github.com/repos/maleck13/ansible-service-broker/milestones{/number}","notifications_url":"https://api.github.com/repos/maleck13/ansible-service-broker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maleck13/ansible-service-broker/labels{/name}","releases_url":"https://api.github.com/repos/maleck13/ansible-service-broker/releases{/id}","deployments_url":"https://api.github.com/repos/maleck13/ansible-service-broker/deployments","created_at":"2017-06-26T15:44:14Z","updated_at":"2017-06-26T15:44:16Z","pushed_at":"2018-03-09T15:50:26Z","git_url":"git://github.com/maleck13/ansible-service-broker.git","ssh_url":"git@github.com:maleck13/ansible-service-broker.git","clone_url":"https://github.com/maleck13/ansible-service-broker.git","svn_url":"https://github.com/maleck13/ansible-service-broker","homepage":null,"size":87450,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openshift:master","ref":"master","sha":"dac85fa7eb7b26515fc5a7c128c3899bcedac0a7","user":{"login":"openshift","id":792337,"avatar_url":"https://avatars3.githubusercontent.com/u/792337?v=4","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"repo":{"id":79371528,"name":"ansible-service-broker","full_name":"openshift/ansible-service-broker","owner":{"login":"openshift","id":792337,"avatar_url":"https://avatars3.githubusercontent.com/u/792337?v=4","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openshift/ansible-service-broker","description":"Ansible Service Broker","fork":false,"url":"https://api.github.com/repos/openshift/ansible-service-broker","forks_url":"https://api.github.com/repos/openshift/ansible-service-broker/forks","keys_url":"https://api.github.com/repos/openshift/ansible-service-broker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openshift/ansible-service-broker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openshift/ansible-service-broker/teams","hooks_url":"https://api.github.com/repos/openshift/ansible-service-broker/hooks","issue_events_url":"https://api.github.com/repos/openshift/ansible-service-broker/issues/events{/number}","events_url":"https://api.github.com/repos/openshift/ansible-service-broker/events","assignees_url":"https://api.github.com/repos/openshift/ansible-service-broker/assignees{/user}","branches_url":"https://api.github.com/repos/openshift/ansible-service-broker/branches{/branch}","tags_url":"https://api.github.com/repos/openshift/ansible-service-broker/tags","blobs_url":"https://api.github.com/repos/openshift/ansible-service-broker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openshift/ansible-service-broker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openshift/ansible-service-broker/git/refs{/sha}","trees_url":"https://api.github.com/repos/openshift/ansible-service-broker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openshift/ansible-service-broker/statuses/{sha}","languages_url":"https://api.github.com/repos/openshift/ansible-service-broker/languages","stargazers_url":"https://api.github.com/repos/openshift/ansible-service-broker/stargazers","contributors_url":"https://api.github.com/repos/openshift/ansible-service-broker/contributors","subscribers_url":"https://api.github.com/repos/openshift/ansible-service-broker/subscribers","subscription_url":"https://api.github.com/repos/openshift/ansible-service-broker/subscription","commits_url":"https://api.github.com/repos/openshift/ansible-service-broker/commits{/sha}","git_commits_url":"https://api.github.com/repos/openshift/ansible-service-broker/git/commits{/sha}","comments_url":"https://api.github.com/repos/openshift/ansible-service-broker/comments{/number}","issue_comment_url":"https://api.github.com/repos/openshift/ansible-service-broker/issues/comments{/number}","contents_url":"https://api.github.com/repos/openshift/ansible-service-broker/contents/{+path}","compare_url":"https://api.github.com/repos/openshift/ansible-service-broker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openshift/ansible-service-broker/merges","archive_url":"https://api.github.com/repos/openshift/ansible-service-broker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openshift/ansible-service-broker/downloads","issues_url":"https://api.github.com/repos/openshift/ansible-service-broker/issues{/number}","pulls_url":"https://api.github.com/repos/openshift/ansible-service-broker/pulls{/number}","milestones_url":"https://api.github.com/repos/openshift/ansible-service-broker/milestones{/number}","notifications_url":"https://api.github.com/repos/openshift/ansible-service-broker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openshift/ansible-service-broker/labels{/name}","releases_url":"https://api.github.com/repos/openshift/ansible-service-broker/releases{/id}","deployments_url":"https://api.github.com/repos/openshift/ansible-service-broker/deployments","created_at":"2017-01-18T18:40:49Z","updated_at":"2018-03-05T14:26:14Z","pushed_at":"2018-03-09T21:06:31Z","git_url":"git://github.com/openshift/ansible-service-broker.git","ssh_url":"git@github.com:openshift/ansible-service-broker.git","clone_url":"https://github.com/openshift/ansible-service-broker.git","svn_url":"https://github.com/openshift/ansible-service-broker","homepage":null,"size":92564,"stargazers_count":92,"watchers_count":92,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":49,"mirror_url":null,"archived":false,"open_issues_count":41,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":49,"open_issues":41,"watchers":92,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/828"},"html":{"href":"https://github.com/openshift/ansible-service-broker/pull/828"},"issue":{"href":"https://api.github.com/repos/openshift/ansible-service-broker/issues/828"},"comments":{"href":"https://api.github.com/repos/openshift/ansible-service-broker/issues/828/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/828/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/ansible-service-broker/pulls/828/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/ansible-service-broker/statuses/f7be0e0414cce527f659e110fa15bc292aa14d1e"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"shawn-hurley"}}