{"action":"created","comment":{"url":"https://api.github.com/repos/HunanTV/eru-agent/pulls/comments/35175508","id":35175508,"diff_hunk":"@@ -0,0 +1,118 @@\n+package api\n+\n+import (\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"strings\"\n+\n+\t\"github.com/HunanTV/eru-agent/app\"\n+\t\"github.com/HunanTV/eru-agent/common\"\n+\t\"github.com/HunanTV/eru-agent/g\"\n+\t\"github.com/HunanTV/eru-agent/lenz\"\n+\t\"github.com/HunanTV/eru-agent/logs\"\n+\t\"github.com/HunanTV/eru-agent/network\"\n+\t\"github.com/keimoon/gore\"\n+)\n+\n+func PubSubServe() {\n+\tgo statusWatcher()\n+\tgo vlanWatcher()\n+}\n+\n+func getRdsConn() *gore.Conn {\n+\tconn, err := g.Rds.Acquire()\n+\tif err != nil || conn == nil {\n+\t\tlogs.Assert(err, \"Get redis conn\")\n+\t}\n+\treturn conn\n+}\n+\n+func releaseConn(conn *gore.Conn) {\n+\tg.Rds.Release(conn)\n+}\n+\n+func vlanWatcher() {\n+\tconn := getRdsConn()\n+\treport := getRdsConn()\n+\tdefer releaseConn(conn)\n+\tdefer releaseConn(report)\n+\n+\tsubs := gore.NewSubscriptions(conn)\n+\tdefer subs.Close()\n+\tsubKey := fmt.Sprintf(\"eru:agent:%s:vlan\", g.Config.HostName)\n+\tlogs.Debug(\"API vlan subscribe\", subKey)\n+\tsubs.Subscribe(subKey)\n+\n+\tfor message := range subs.Message() {\n+\t\tif message == nil {\n+\t\t\tlogs.Info(\"API vLan watcher shutdown\")\n+\t\t\tbreak\n+\t\t}\n+\t\tcommand := string(message.Message)\n+\t\tlogs.Debug(\"API vlan watcher get\", command)\n+\t\tparser := strings.Split(command, \"|\")\n+\t\tif len(parser) <= 3 {","path":"api/pubsub.go","position":54,"original_position":54,"commit_id":"913bd7062e677fc1fd8bd3300378c2164f23be72","original_commit_id":"913bd7062e677fc1fd8bd3300378c2164f23be72","user":{"login":"tonicbupt","id":1748597,"avatar_url":"https://avatars.githubusercontent.com/u/1748597?v=3","gravatar_id":"","url":"https://api.github.com/users/tonicbupt","html_url":"https://github.com/tonicbupt","followers_url":"https://api.github.com/users/tonicbupt/followers","following_url":"https://api.github.com/users/tonicbupt/following{/other_user}","gists_url":"https://api.github.com/users/tonicbupt/gists{/gist_id}","starred_url":"https://api.github.com/users/tonicbupt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonicbupt/subscriptions","organizations_url":"https://api.github.com/users/tonicbupt/orgs","repos_url":"https://api.github.com/users/tonicbupt/repos","events_url":"https://api.github.com/users/tonicbupt/events{/privacy}","received_events_url":"https://api.github.com/users/tonicbupt/received_events","type":"User","site_admin":false},"body":"这里你自己设定的就是3","created_at":"2015-07-22T02:13:05Z","updated_at":"2015-07-22T02:13:05Z","html_url":"https://github.com/HunanTV/eru-agent/pull/23#discussion_r35175508","pull_request_url":"https://api.github.com/repos/HunanTV/eru-agent/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/HunanTV/eru-agent/pulls/comments/35175508"},"html":{"href":"https://github.com/HunanTV/eru-agent/pull/23#discussion_r35175508"},"pull_request":{"href":"https://api.github.com/repos/HunanTV/eru-agent/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/HunanTV/eru-agent/pulls/23","id":40427839,"html_url":"https://github.com/HunanTV/eru-agent/pull/23","diff_url":"https://github.com/HunanTV/eru-agent/pull/23.diff","patch_url":"https://github.com/HunanTV/eru-agent/pull/23.patch","issue_url":"https://api.github.com/repos/HunanTV/eru-agent/issues/23","number":23,"state":"closed","locked":false,"title":"version 0.1.2","user":{"login":"CMGS","id":506216,"avatar_url":"https://avatars.githubusercontent.com/u/506216?v=3","gravatar_id":"","url":"https://api.github.com/users/CMGS","html_url":"https://github.com/CMGS","followers_url":"https://api.github.com/users/CMGS/followers","following_url":"https://api.github.com/users/CMGS/following{/other_user}","gists_url":"https://api.github.com/users/CMGS/gists{/gist_id}","starred_url":"https://api.github.com/users/CMGS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CMGS/subscriptions","organizations_url":"https://api.github.com/users/CMGS/orgs","repos_url":"https://api.github.com/users/CMGS/repos","events_url":"https://api.github.com/users/CMGS/events{/privacy}","received_events_url":"https://api.github.com/users/CMGS/received_events","type":"User","site_admin":false},"body":"没有完成 HTTP 接口","created_at":"2015-07-21T07:00:13Z","updated_at":"2015-07-22T02:13:05Z","closed_at":"2015-07-21T07:04:14Z","merged_at":"2015-07-21T07:04:14Z","merge_commit_sha":"bd16d1172621e7137b425a24e46ee6027ef012a8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/HunanTV/eru-agent/pulls/23/commits","review_comments_url":"https://api.github.com/repos/HunanTV/eru-agent/pulls/23/comments","review_comment_url":"https://api.github.com/repos/HunanTV/eru-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/HunanTV/eru-agent/issues/23/comments","statuses_url":"https://api.github.com/repos/HunanTV/eru-agent/statuses/913bd7062e677fc1fd8bd3300378c2164f23be72","head":{"label":"HunanTV:0.1.2.1","ref":"0.1.2.1","sha":"913bd7062e677fc1fd8bd3300378c2164f23be72","user":{"login":"HunanTV","id":8850915,"avatar_url":"https://avatars.githubusercontent.com/u/8850915?v=3","gravatar_id":"","url":"https://api.github.com/users/HunanTV","html_url":"https://github.com/HunanTV","followers_url":"https://api.github.com/users/HunanTV/followers","following_url":"https://api.github.com/users/HunanTV/following{/other_user}","gists_url":"https://api.github.com/users/HunanTV/gists{/gist_id}","starred_url":"https://api.github.com/users/HunanTV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HunanTV/subscriptions","organizations_url":"https://api.github.com/users/HunanTV/orgs","repos_url":"https://api.github.com/users/HunanTV/repos","events_url":"https://api.github.com/users/HunanTV/events{/privacy}","received_events_url":"https://api.github.com/users/HunanTV/received_events","type":"Organization","site_admin":false},"repo":{"id":31401535,"name":"eru-agent","full_name":"HunanTV/eru-agent","owner":{"login":"HunanTV","id":8850915,"avatar_url":"https://avatars.githubusercontent.com/u/8850915?v=3","gravatar_id":"","url":"https://api.github.com/users/HunanTV","html_url":"https://github.com/HunanTV","followers_url":"https://api.github.com/users/HunanTV/followers","following_url":"https://api.github.com/users/HunanTV/following{/other_user}","gists_url":"https://api.github.com/users/HunanTV/gists{/gist_id}","starred_url":"https://api.github.com/users/HunanTV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HunanTV/subscriptions","organizations_url":"https://api.github.com/users/HunanTV/orgs","repos_url":"https://api.github.com/users/HunanTV/repos","events_url":"https://api.github.com/users/HunanTV/events{/privacy}","received_events_url":"https://api.github.com/users/HunanTV/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HunanTV/eru-agent","description":"Agent of Project Eru","fork":false,"url":"https://api.github.com/repos/HunanTV/eru-agent","forks_url":"https://api.github.com/repos/HunanTV/eru-agent/forks","keys_url":"https://api.github.com/repos/HunanTV/eru-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HunanTV/eru-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HunanTV/eru-agent/teams","hooks_url":"https://api.github.com/repos/HunanTV/eru-agent/hooks","issue_events_url":"https://api.github.com/repos/HunanTV/eru-agent/issues/events{/number}","events_url":"https://api.github.com/repos/HunanTV/eru-agent/events","assignees_url":"https://api.github.com/repos/HunanTV/eru-agent/assignees{/user}","branches_url":"https://api.github.com/repos/HunanTV/eru-agent/branches{/branch}","tags_url":"https://api.github.com/repos/HunanTV/eru-agent/tags","blobs_url":"https://api.github.com/repos/HunanTV/eru-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HunanTV/eru-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HunanTV/eru-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/HunanTV/eru-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HunanTV/eru-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/HunanTV/eru-agent/languages","stargazers_url":"https://api.github.com/repos/HunanTV/eru-agent/stargazers","contributors_url":"https://api.github.com/repos/HunanTV/eru-agent/contributors","subscribers_url":"https://api.github.com/repos/HunanTV/eru-agent/subscribers","subscription_url":"https://api.github.com/repos/HunanTV/eru-agent/subscription","commits_url":"https://api.github.com/repos/HunanTV/eru-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/HunanTV/eru-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/HunanTV/eru-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/HunanTV/eru-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/HunanTV/eru-agent/contents/{+path}","compare_url":"https://api.github.com/repos/HunanTV/eru-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HunanTV/eru-agent/merges","archive_url":"https://api.github.com/repos/HunanTV/eru-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HunanTV/eru-agent/downloads","issues_url":"https://api.github.com/repos/HunanTV/eru-agent/issues{/number}","pulls_url":"https://api.github.com/repos/HunanTV/eru-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/HunanTV/eru-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/HunanTV/eru-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HunanTV/eru-agent/labels{/name}","releases_url":"https://api.github.com/repos/HunanTV/eru-agent/releases{/id}","created_at":"2015-02-27T03:21:26Z","updated_at":"2015-06-04T14:39:51Z","pushed_at":"2015-07-21T09:57:14Z","git_url":"git://github.com/HunanTV/eru-agent.git","ssh_url":"git@github.com:HunanTV/eru-agent.git","clone_url":"https://github.com/HunanTV/eru-agent.git","svn_url":"https://github.com/HunanTV/eru-agent","homepage":null,"size":588,"stargazers_count":13,"watchers_count":13,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":0,"forks":6,"open_issues":0,"watchers":13,"default_branch":"master"}},"base":{"label":"HunanTV:master","ref":"master","sha":"fa9f8df94692d8e1672123d621ba07dc3c793462","user":{"login":"HunanTV","id":8850915,"avatar_url":"https://avatars.githubusercontent.com/u/8850915?v=3","gravatar_id":"","url":"https://api.github.com/users/HunanTV","html_url":"https://github.com/HunanTV","followers_url":"https://api.github.com/users/HunanTV/followers","following_url":"https://api.github.com/users/HunanTV/following{/other_user}","gists_url":"https://api.github.com/users/HunanTV/gists{/gist_id}","starred_url":"https://api.github.com/users/HunanTV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HunanTV/subscriptions","organizations_url":"https://api.github.com/users/HunanTV/orgs","repos_url":"https://api.github.com/users/HunanTV/repos","events_url":"https://api.github.com/users/HunanTV/events{/privacy}","received_events_url":"https://api.github.com/users/HunanTV/received_events","type":"Organization","site_admin":false},"repo":{"id":31401535,"name":"eru-agent","full_name":"HunanTV/eru-agent","owner":{"login":"HunanTV","id":8850915,"avatar_url":"https://avatars.githubusercontent.com/u/8850915?v=3","gravatar_id":"","url":"https://api.github.com/users/HunanTV","html_url":"https://github.com/HunanTV","followers_url":"https://api.github.com/users/HunanTV/followers","following_url":"https://api.github.com/users/HunanTV/following{/other_user}","gists_url":"https://api.github.com/users/HunanTV/gists{/gist_id}","starred_url":"https://api.github.com/users/HunanTV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HunanTV/subscriptions","organizations_url":"https://api.github.com/users/HunanTV/orgs","repos_url":"https://api.github.com/users/HunanTV/repos","events_url":"https://api.github.com/users/HunanTV/events{/privacy}","received_events_url":"https://api.github.com/users/HunanTV/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HunanTV/eru-agent","description":"Agent of Project Eru","fork":false,"url":"https://api.github.com/repos/HunanTV/eru-agent","forks_url":"https://api.github.com/repos/HunanTV/eru-agent/forks","keys_url":"https://api.github.com/repos/HunanTV/eru-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HunanTV/eru-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HunanTV/eru-agent/teams","hooks_url":"https://api.github.com/repos/HunanTV/eru-agent/hooks","issue_events_url":"https://api.github.com/repos/HunanTV/eru-agent/issues/events{/number}","events_url":"https://api.github.com/repos/HunanTV/eru-agent/events","assignees_url":"https://api.github.com/repos/HunanTV/eru-agent/assignees{/user}","branches_url":"https://api.github.com/repos/HunanTV/eru-agent/branches{/branch}","tags_url":"https://api.github.com/repos/HunanTV/eru-agent/tags","blobs_url":"https://api.github.com/repos/HunanTV/eru-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HunanTV/eru-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HunanTV/eru-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/HunanTV/eru-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HunanTV/eru-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/HunanTV/eru-agent/languages","stargazers_url":"https://api.github.com/repos/HunanTV/eru-agent/stargazers","contributors_url":"https://api.github.com/repos/HunanTV/eru-agent/contributors","subscribers_url":"https://api.github.com/repos/HunanTV/eru-agent/subscribers","subscription_url":"https://api.github.com/repos/HunanTV/eru-agent/subscription","commits_url":"https://api.github.com/repos/HunanTV/eru-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/HunanTV/eru-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/HunanTV/eru-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/HunanTV/eru-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/HunanTV/eru-agent/contents/{+path}","compare_url":"https://api.github.com/repos/HunanTV/eru-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HunanTV/eru-agent/merges","archive_url":"https://api.github.com/repos/HunanTV/eru-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HunanTV/eru-agent/downloads","issues_url":"https://api.github.com/repos/HunanTV/eru-agent/issues{/number}","pulls_url":"https://api.github.com/repos/HunanTV/eru-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/HunanTV/eru-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/HunanTV/eru-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HunanTV/eru-agent/labels{/name}","releases_url":"https://api.github.com/repos/HunanTV/eru-agent/releases{/id}","created_at":"2015-02-27T03:21:26Z","updated_at":"2015-06-04T14:39:51Z","pushed_at":"2015-07-21T09:57:14Z","git_url":"git://github.com/HunanTV/eru-agent.git","ssh_url":"git@github.com:HunanTV/eru-agent.git","clone_url":"https://github.com/HunanTV/eru-agent.git","svn_url":"https://github.com/HunanTV/eru-agent","homepage":null,"size":588,"stargazers_count":13,"watchers_count":13,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":0,"forks":6,"open_issues":0,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/HunanTV/eru-agent/pulls/23"},"html":{"href":"https://github.com/HunanTV/eru-agent/pull/23"},"issue":{"href":"https://api.github.com/repos/HunanTV/eru-agent/issues/23"},"comments":{"href":"https://api.github.com/repos/HunanTV/eru-agent/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/HunanTV/eru-agent/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/HunanTV/eru-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/HunanTV/eru-agent/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/HunanTV/eru-agent/statuses/913bd7062e677fc1fd8bd3300378c2164f23be72"}}}}