{"action":"created","comment":{"url":"https://api.github.com/repos/twitter/finagle/pulls/comments/60413243","id":60413243,"diff_hunk":"@@ -0,0 +1,95 @@\n+package com.twitter.finagle.loadbalancer\n+\n+import com.twitter.finagle.{ClientConnection, NoBrokersAvailableException, Service,\n+  ServiceFactory, ServiceFactoryProxy, Status}\n+import com.twitter.finagle.service.FailingFactory\n+import com.twitter.finagle.stats.StatsReceiver\n+import com.twitter.util.{Activity, Future, Promise, Time}\n+\n+/**\n+ * A simple sticky load balancer which selects the first backend it\n+ * can connect to and sticks to it unless that backend is not functioning\n+ * properly, in which case it will change to another functioning backend.\n+ */\n+class StickyBalancer[Req, Rep](\n+    val activity: Activity[Traversable[ServiceFactory[Req, Rep]]],\n+    val statsReceiver: StatsReceiver,\n+    val emptyException: NoBrokersAvailableException,\n+    val maxEffort: Int = 5)\n+  extends ServiceFactory[Req, Rep]\n+  with Balancer[Req, Rep]\n+  with Updating[Req, Rep] {\n+\n+  // For the OnReady mixin\n+  private[this] val ready = new Promise[Unit]","path":"finagle-core/src/main/scala/com/twitter/finagle/loadbalancer/Sticky.scala","position":24,"original_position":24,"commit_id":"bb61f0c694e808fd045c13a446ca182b2f9ec58a","original_commit_id":"bb61f0c694e808fd045c13a446ca182b2f9ec58a","user":{"login":"mosesn","id":156562,"avatar_url":"https://avatars.githubusercontent.com/u/156562?v=3","gravatar_id":"","url":"https://api.github.com/users/mosesn","html_url":"https://github.com/mosesn","followers_url":"https://api.github.com/users/mosesn/followers","following_url":"https://api.github.com/users/mosesn/following{/other_user}","gists_url":"https://api.github.com/users/mosesn/gists{/gist_id}","starred_url":"https://api.github.com/users/mosesn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mosesn/subscriptions","organizations_url":"https://api.github.com/users/mosesn/orgs","repos_url":"https://api.github.com/users/mosesn/repos","events_url":"https://api.github.com/users/mosesn/events{/privacy}","received_events_url":"https://api.github.com/users/mosesn/received_events","type":"User","site_admin":false},"body":"you never satisfy this promise","created_at":"2016-04-20T14:08:10Z","updated_at":"2016-04-20T14:08:10Z","html_url":"https://github.com/twitter/finagle/pull/497#discussion_r60413243","pull_request_url":"https://api.github.com/repos/twitter/finagle/pulls/497","_links":{"self":{"href":"https://api.github.com/repos/twitter/finagle/pulls/comments/60413243"},"html":{"href":"https://github.com/twitter/finagle/pull/497#discussion_r60413243"},"pull_request":{"href":"https://api.github.com/repos/twitter/finagle/pulls/497"}}},"pull_request":{"url":"https://api.github.com/repos/twitter/finagle/pulls/497","id":67145536,"html_url":"https://github.com/twitter/finagle/pull/497","diff_url":"https://github.com/twitter/finagle/pull/497.diff","patch_url":"https://github.com/twitter/finagle/pull/497.patch","issue_url":"https://api.github.com/repos/twitter/finagle/issues/497","number":497,"state":"open","locked":false,"title":"Add Sticky Load Balancer which connects to one host and sticks to it.","user":{"login":"johanstenberg92","id":1280550,"avatar_url":"https://avatars.githubusercontent.com/u/1280550?v=3","gravatar_id":"","url":"https://api.github.com/users/johanstenberg92","html_url":"https://github.com/johanstenberg92","followers_url":"https://api.github.com/users/johanstenberg92/followers","following_url":"https://api.github.com/users/johanstenberg92/following{/other_user}","gists_url":"https://api.github.com/users/johanstenberg92/gists{/gist_id}","starred_url":"https://api.github.com/users/johanstenberg92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanstenberg92/subscriptions","organizations_url":"https://api.github.com/users/johanstenberg92/orgs","repos_url":"https://api.github.com/users/johanstenberg92/repos","events_url":"https://api.github.com/users/johanstenberg92/events{/privacy}","received_events_url":"https://api.github.com/users/johanstenberg92/received_events","type":"User","site_admin":false},"body":"Problem\r\n\r\nIf you use Finagle for services which aren't identical replicas such as\r\nsystems using strong eventual consistency, you can't currently use any provided\r\nload balancers since they treat all hosts as replicas.\r\n\r\nSolution\r\n\r\nThis PR adds a new load balancer sticking to the first backend it can connect\r\nto. It only changes backend if the initial backend is not reachable. This allows\r\nFinagle clients to be used in systems using (strong) eventual consistency.","created_at":"2016-04-20T08:19:22Z","updated_at":"2016-04-20T14:08:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a2f4d004cbb31f9b982d58b954a03733515e2aa2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/twitter/finagle/pulls/497/commits","review_comments_url":"https://api.github.com/repos/twitter/finagle/pulls/497/comments","review_comment_url":"https://api.github.com/repos/twitter/finagle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/twitter/finagle/issues/497/comments","statuses_url":"https://api.github.com/repos/twitter/finagle/statuses/bb61f0c694e808fd045c13a446ca182b2f9ec58a","head":{"label":"johanstenberg92:sticky-load-balancer","ref":"sticky-load-balancer","sha":"bb61f0c694e808fd045c13a446ca182b2f9ec58a","user":{"login":"johanstenberg92","id":1280550,"avatar_url":"https://avatars.githubusercontent.com/u/1280550?v=3","gravatar_id":"","url":"https://api.github.com/users/johanstenberg92","html_url":"https://github.com/johanstenberg92","followers_url":"https://api.github.com/users/johanstenberg92/followers","following_url":"https://api.github.com/users/johanstenberg92/following{/other_user}","gists_url":"https://api.github.com/users/johanstenberg92/gists{/gist_id}","starred_url":"https://api.github.com/users/johanstenberg92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanstenberg92/subscriptions","organizations_url":"https://api.github.com/users/johanstenberg92/orgs","repos_url":"https://api.github.com/users/johanstenberg92/repos","events_url":"https://api.github.com/users/johanstenberg92/events{/privacy}","received_events_url":"https://api.github.com/users/johanstenberg92/received_events","type":"User","site_admin":false},"repo":{"id":56663791,"name":"finagle","full_name":"johanstenberg92/finagle","owner":{"login":"johanstenberg92","id":1280550,"avatar_url":"https://avatars.githubusercontent.com/u/1280550?v=3","gravatar_id":"","url":"https://api.github.com/users/johanstenberg92","html_url":"https://github.com/johanstenberg92","followers_url":"https://api.github.com/users/johanstenberg92/followers","following_url":"https://api.github.com/users/johanstenberg92/following{/other_user}","gists_url":"https://api.github.com/users/johanstenberg92/gists{/gist_id}","starred_url":"https://api.github.com/users/johanstenberg92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanstenberg92/subscriptions","organizations_url":"https://api.github.com/users/johanstenberg92/orgs","repos_url":"https://api.github.com/users/johanstenberg92/repos","events_url":"https://api.github.com/users/johanstenberg92/events{/privacy}","received_events_url":"https://api.github.com/users/johanstenberg92/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/johanstenberg92/finagle","description":"A fault tolerant, protocol-agnostic RPC system","fork":true,"url":"https://api.github.com/repos/johanstenberg92/finagle","forks_url":"https://api.github.com/repos/johanstenberg92/finagle/forks","keys_url":"https://api.github.com/repos/johanstenberg92/finagle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/johanstenberg92/finagle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/johanstenberg92/finagle/teams","hooks_url":"https://api.github.com/repos/johanstenberg92/finagle/hooks","issue_events_url":"https://api.github.com/repos/johanstenberg92/finagle/issues/events{/number}","events_url":"https://api.github.com/repos/johanstenberg92/finagle/events","assignees_url":"https://api.github.com/repos/johanstenberg92/finagle/assignees{/user}","branches_url":"https://api.github.com/repos/johanstenberg92/finagle/branches{/branch}","tags_url":"https://api.github.com/repos/johanstenberg92/finagle/tags","blobs_url":"https://api.github.com/repos/johanstenberg92/finagle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/johanstenberg92/finagle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/johanstenberg92/finagle/git/refs{/sha}","trees_url":"https://api.github.com/repos/johanstenberg92/finagle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/johanstenberg92/finagle/statuses/{sha}","languages_url":"https://api.github.com/repos/johanstenberg92/finagle/languages","stargazers_url":"https://api.github.com/repos/johanstenberg92/finagle/stargazers","contributors_url":"https://api.github.com/repos/johanstenberg92/finagle/contributors","subscribers_url":"https://api.github.com/repos/johanstenberg92/finagle/subscribers","subscription_url":"https://api.github.com/repos/johanstenberg92/finagle/subscription","commits_url":"https://api.github.com/repos/johanstenberg92/finagle/commits{/sha}","git_commits_url":"https://api.github.com/repos/johanstenberg92/finagle/git/commits{/sha}","comments_url":"https://api.github.com/repos/johanstenberg92/finagle/comments{/number}","issue_comment_url":"https://api.github.com/repos/johanstenberg92/finagle/issues/comments{/number}","contents_url":"https://api.github.com/repos/johanstenberg92/finagle/contents/{+path}","compare_url":"https://api.github.com/repos/johanstenberg92/finagle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/johanstenberg92/finagle/merges","archive_url":"https://api.github.com/repos/johanstenberg92/finagle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/johanstenberg92/finagle/downloads","issues_url":"https://api.github.com/repos/johanstenberg92/finagle/issues{/number}","pulls_url":"https://api.github.com/repos/johanstenberg92/finagle/pulls{/number}","milestones_url":"https://api.github.com/repos/johanstenberg92/finagle/milestones{/number}","notifications_url":"https://api.github.com/repos/johanstenberg92/finagle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/johanstenberg92/finagle/labels{/name}","releases_url":"https://api.github.com/repos/johanstenberg92/finagle/releases{/id}","deployments_url":"https://api.github.com/repos/johanstenberg92/finagle/deployments","created_at":"2016-04-20T07:04:28Z","updated_at":"2016-04-20T07:04:32Z","pushed_at":"2016-04-20T08:18:40Z","git_url":"git://github.com/johanstenberg92/finagle.git","ssh_url":"git@github.com:johanstenberg92/finagle.git","clone_url":"https://github.com/johanstenberg92/finagle.git","svn_url":"https://github.com/johanstenberg92/finagle","homepage":"http://twitter.github.io/finagle","size":38169,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"twitter:develop","ref":"develop","sha":"6ad925a0e94e9575f56afb1d7b0ecc575f29ba9b","user":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"repo":{"id":1007362,"name":"finagle","full_name":"twitter/finagle","owner":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/twitter/finagle","description":"A fault tolerant, protocol-agnostic RPC system","fork":false,"url":"https://api.github.com/repos/twitter/finagle","forks_url":"https://api.github.com/repos/twitter/finagle/forks","keys_url":"https://api.github.com/repos/twitter/finagle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twitter/finagle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twitter/finagle/teams","hooks_url":"https://api.github.com/repos/twitter/finagle/hooks","issue_events_url":"https://api.github.com/repos/twitter/finagle/issues/events{/number}","events_url":"https://api.github.com/repos/twitter/finagle/events","assignees_url":"https://api.github.com/repos/twitter/finagle/assignees{/user}","branches_url":"https://api.github.com/repos/twitter/finagle/branches{/branch}","tags_url":"https://api.github.com/repos/twitter/finagle/tags","blobs_url":"https://api.github.com/repos/twitter/finagle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twitter/finagle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twitter/finagle/git/refs{/sha}","trees_url":"https://api.github.com/repos/twitter/finagle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twitter/finagle/statuses/{sha}","languages_url":"https://api.github.com/repos/twitter/finagle/languages","stargazers_url":"https://api.github.com/repos/twitter/finagle/stargazers","contributors_url":"https://api.github.com/repos/twitter/finagle/contributors","subscribers_url":"https://api.github.com/repos/twitter/finagle/subscribers","subscription_url":"https://api.github.com/repos/twitter/finagle/subscription","commits_url":"https://api.github.com/repos/twitter/finagle/commits{/sha}","git_commits_url":"https://api.github.com/repos/twitter/finagle/git/commits{/sha}","comments_url":"https://api.github.com/repos/twitter/finagle/comments{/number}","issue_comment_url":"https://api.github.com/repos/twitter/finagle/issues/comments{/number}","contents_url":"https://api.github.com/repos/twitter/finagle/contents/{+path}","compare_url":"https://api.github.com/repos/twitter/finagle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twitter/finagle/merges","archive_url":"https://api.github.com/repos/twitter/finagle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twitter/finagle/downloads","issues_url":"https://api.github.com/repos/twitter/finagle/issues{/number}","pulls_url":"https://api.github.com/repos/twitter/finagle/pulls{/number}","milestones_url":"https://api.github.com/repos/twitter/finagle/milestones{/number}","notifications_url":"https://api.github.com/repos/twitter/finagle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twitter/finagle/labels{/name}","releases_url":"https://api.github.com/repos/twitter/finagle/releases{/id}","deployments_url":"https://api.github.com/repos/twitter/finagle/deployments","created_at":"2010-10-19T22:10:09Z","updated_at":"2016-04-20T13:30:12Z","pushed_at":"2016-04-20T08:19:22Z","git_url":"git://github.com/twitter/finagle.git","ssh_url":"git@github.com:twitter/finagle.git","clone_url":"https://github.com/twitter/finagle.git","svn_url":"https://github.com/twitter/finagle","homepage":"http://twitter.github.io/finagle","size":43034,"stargazers_count":4529,"watchers_count":4529,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":860,"mirror_url":null,"open_issues_count":51,"forks":860,"open_issues":51,"watchers":4529,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/twitter/finagle/pulls/497"},"html":{"href":"https://github.com/twitter/finagle/pull/497"},"issue":{"href":"https://api.github.com/repos/twitter/finagle/issues/497"},"comments":{"href":"https://api.github.com/repos/twitter/finagle/issues/497/comments"},"review_comments":{"href":"https://api.github.com/repos/twitter/finagle/pulls/497/comments"},"review_comment":{"href":"https://api.github.com/repos/twitter/finagle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/twitter/finagle/pulls/497/commits"},"statuses":{"href":"https://api.github.com/repos/twitter/finagle/statuses/bb61f0c694e808fd045c13a446ca182b2f9ec58a"}}}}