{"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/pandora/pulls/comments/27972488","id":27972488,"diff_hunk":"@@ -0,0 +1,62 @@\n+package com.wikia.dropwizard.consul.registration.actors;\n+\n+import com.wikia.dropwizard.consul.registration.events.HostingPortChanged;\n+import com.wikia.dropwizard.consul.registration.events.RegistrationRequest;\n+import com.wikia.dropwizard.consul.registration.events.ShutdownRequest;\n+import com.wikia.dropwizard.consul.registration.guice.ConsulBus;\n+import com.wikia.dropwizard.consul.registration.util.Consular;\n+\n+import com.google.common.eventbus.EventBus;\n+import com.google.common.eventbus.Subscribe;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import javax.inject.Inject;\n+\n+public class Registrator {\n+\n+  private final static Logger LOG = LoggerFactory.getLogger(Registrator.class);\n+  private final ServiceIdProvider serviceIdProvider;\n+  private Consular consular;\n+  private EventBus eventBus;\n+  private Integer portNumber = 0;\n+\n+  @Inject\n+  public Registrator(Consular consular, ServiceIdProvider serviceIdProvider,\n+                     @ConsulBus EventBus eventBus) {\n+    this.consular = consular;\n+    this.serviceIdProvider = serviceIdProvider;\n+    this.eventBus = eventBus;\n+    this.eventBus.register(this);\n+  }\n+\n+  @Subscribe\n+  public void registationRequested(RegistrationRequest unused) {\n+    doRegister();\n+  }\n+\n+  @Subscribe\n+  public void portChanged(HostingPortChanged event) {\n+    portNumber = event.getPortNumber();\n+    doRegister();\n+  }\n+\n+  @Subscribe\n+  public void shutdownRequested(ShutdownRequest unused) {\n+    this.eventBus.unregister(this);\n+  }\n+\n+  private void doRegister() {\n+    if (portNumber > 0) {\n+      try {\n+        serviceIdProvider.get()\n+            .ifPresent(serviceId -> this.consular.registerInConsul(2, serviceId));\n+      } catch (RuntimeException ex) {\n+        LOG.error(\"Registration failure\", ex.getCause().getMessage());","path":"lib/dropwizard/consul/src/main/java/com/wikia/dropwizard/consul/registration/actors/Registrator.java","position":55,"original_position":55,"commit_id":"6f465757f9e7dfa917bd99649c9d9d9349d45821","original_commit_id":"0ab2648fca093e852bf4f6f84bcf7ff41b95bc87","user":{"login":"pchojnacki","id":812891,"avatar_url":"https://avatars.githubusercontent.com/u/812891?v=3","gravatar_id":"","url":"https://api.github.com/users/pchojnacki","html_url":"https://github.com/pchojnacki","followers_url":"https://api.github.com/users/pchojnacki/followers","following_url":"https://api.github.com/users/pchojnacki/following{/other_user}","gists_url":"https://api.github.com/users/pchojnacki/gists{/gist_id}","starred_url":"https://api.github.com/users/pchojnacki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pchojnacki/subscriptions","organizations_url":"https://api.github.com/users/pchojnacki/orgs","repos_url":"https://api.github.com/users/pchojnacki/repos","events_url":"https://api.github.com/users/pchojnacki/events{/privacy}","received_events_url":"https://api.github.com/users/pchojnacki/received_events","type":"User","site_admin":false},"body":"I'll change the log to log all stacktrace.\r\nBut while this error is 'fatal'  the application is expected to recover from it.","created_at":"2015-04-08T14:09:40Z","updated_at":"2015-04-08T14:09:40Z","html_url":"https://github.com/Wikia/pandora/pull/144#discussion_r27972488","pull_request_url":"https://api.github.com/repos/Wikia/pandora/pulls/144","_links":{"self":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/comments/27972488"},"html":{"href":"https://github.com/Wikia/pandora/pull/144#discussion_r27972488"},"pull_request":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/144"}}},"pull_request":{"url":"https://api.github.com/repos/Wikia/pandora/pulls/144","id":32757849,"html_url":"https://github.com/Wikia/pandora/pull/144","diff_url":"https://github.com/Wikia/pandora/pull/144.diff","patch_url":"https://github.com/Wikia/pandora/pull/144.patch","issue_url":"https://api.github.com/repos/Wikia/pandora/issues/144","number":144,"state":"open","locked":false,"title":"SERVICES-148 Consul state registration fixes","user":{"login":"pchojnacki","id":812891,"avatar_url":"https://avatars.githubusercontent.com/u/812891?v=3","gravatar_id":"","url":"https://api.github.com/users/pchojnacki","html_url":"https://github.com/pchojnacki","followers_url":"https://api.github.com/users/pchojnacki/followers","following_url":"https://api.github.com/users/pchojnacki/following{/other_user}","gists_url":"https://api.github.com/users/pchojnacki/gists{/gist_id}","starred_url":"https://api.github.com/users/pchojnacki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pchojnacki/subscriptions","organizations_url":"https://api.github.com/users/pchojnacki/orgs","repos_url":"https://api.github.com/users/pchojnacki/repos","events_url":"https://api.github.com/users/pchojnacki/events{/privacy}","received_events_url":"https://api.github.com/users/pchojnacki/received_events","type":"User","site_admin":false},"body":"- Unify Consul configuration.\r\n- Make Consul Reregister itself when it is deregistered.\r\n- Make failing heartbeats non fatal\r\n- Cleanup build scripts to not clobber environment settings\r\n- Make Consul deregister itself when the application shuts down.\r\n- All services converted to use new deployment configuration","created_at":"2015-04-07T12:11:44Z","updated_at":"2015-04-08T14:09:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1f484ebc63aa1966e55324264f30f4ec7019816d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/pandora/pulls/144/commits","review_comments_url":"https://api.github.com/repos/Wikia/pandora/pulls/144/comments","review_comment_url":"https://api.github.com/repos/Wikia/pandora/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Wikia/pandora/issues/144/comments","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/6f465757f9e7dfa917bd99649c9d9d9349d45821","head":{"label":"Wikia:consul_fixxxesss","ref":"consul_fixxxesss","sha":"6f465757f9e7dfa917bd99649c9d9d9349d45821","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":26663749,"name":"pandora","full_name":"Wikia/pandora","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/pandora","description":"API Service","fork":false,"url":"https://api.github.com/repos/Wikia/pandora","forks_url":"https://api.github.com/repos/Wikia/pandora/forks","keys_url":"https://api.github.com/repos/Wikia/pandora/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/pandora/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/pandora/teams","hooks_url":"https://api.github.com/repos/Wikia/pandora/hooks","issue_events_url":"https://api.github.com/repos/Wikia/pandora/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/pandora/events","assignees_url":"https://api.github.com/repos/Wikia/pandora/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/pandora/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/pandora/tags","blobs_url":"https://api.github.com/repos/Wikia/pandora/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/pandora/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/pandora/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/pandora/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/pandora/languages","stargazers_url":"https://api.github.com/repos/Wikia/pandora/stargazers","contributors_url":"https://api.github.com/repos/Wikia/pandora/contributors","subscribers_url":"https://api.github.com/repos/Wikia/pandora/subscribers","subscription_url":"https://api.github.com/repos/Wikia/pandora/subscription","commits_url":"https://api.github.com/repos/Wikia/pandora/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/pandora/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/pandora/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/pandora/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/pandora/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/pandora/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/pandora/merges","archive_url":"https://api.github.com/repos/Wikia/pandora/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/pandora/downloads","issues_url":"https://api.github.com/repos/Wikia/pandora/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/pandora/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/pandora/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/pandora/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/pandora/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/pandora/releases{/id}","created_at":"2014-11-15T00:29:06Z","updated_at":"2015-04-08T11:52:13Z","pushed_at":"2015-04-08T13:22:21Z","git_url":"git://github.com/Wikia/pandora.git","ssh_url":"git@github.com:Wikia/pandora.git","clone_url":"https://github.com/Wikia/pandora.git","svn_url":"https://github.com/Wikia/pandora","homepage":null,"size":7139,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":3,"default_branch":"master"}},"base":{"label":"Wikia:master","ref":"master","sha":"453b385ca4094e8b7e3fb814226e57aafe3733f1","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":26663749,"name":"pandora","full_name":"Wikia/pandora","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/pandora","description":"API Service","fork":false,"url":"https://api.github.com/repos/Wikia/pandora","forks_url":"https://api.github.com/repos/Wikia/pandora/forks","keys_url":"https://api.github.com/repos/Wikia/pandora/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/pandora/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/pandora/teams","hooks_url":"https://api.github.com/repos/Wikia/pandora/hooks","issue_events_url":"https://api.github.com/repos/Wikia/pandora/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/pandora/events","assignees_url":"https://api.github.com/repos/Wikia/pandora/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/pandora/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/pandora/tags","blobs_url":"https://api.github.com/repos/Wikia/pandora/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/pandora/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/pandora/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/pandora/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/pandora/languages","stargazers_url":"https://api.github.com/repos/Wikia/pandora/stargazers","contributors_url":"https://api.github.com/repos/Wikia/pandora/contributors","subscribers_url":"https://api.github.com/repos/Wikia/pandora/subscribers","subscription_url":"https://api.github.com/repos/Wikia/pandora/subscription","commits_url":"https://api.github.com/repos/Wikia/pandora/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/pandora/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/pandora/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/pandora/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/pandora/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/pandora/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/pandora/merges","archive_url":"https://api.github.com/repos/Wikia/pandora/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/pandora/downloads","issues_url":"https://api.github.com/repos/Wikia/pandora/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/pandora/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/pandora/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/pandora/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/pandora/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/pandora/releases{/id}","created_at":"2014-11-15T00:29:06Z","updated_at":"2015-04-08T11:52:13Z","pushed_at":"2015-04-08T13:22:21Z","git_url":"git://github.com/Wikia/pandora.git","ssh_url":"git@github.com:Wikia/pandora.git","clone_url":"https://github.com/Wikia/pandora.git","svn_url":"https://github.com/Wikia/pandora","homepage":null,"size":7139,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/144"},"html":{"href":"https://github.com/Wikia/pandora/pull/144"},"issue":{"href":"https://api.github.com/repos/Wikia/pandora/issues/144"},"comments":{"href":"https://api.github.com/repos/Wikia/pandora/issues/144/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/144/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/144/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/pandora/statuses/6f465757f9e7dfa917bd99649c9d9d9349d45821"}}}}