{"action":"created","comment":{"url":"https://api.github.com/repos/twitter/finagle/pulls/comments/30470625","id":30470625,"diff_hunk":"@@ -0,0 +1,147 @@\n+package com.twitter.finagle.redis\n+\n+import com.twitter.finagle.redis.protocol._\n+import com.twitter.finagle.redis.util.ReplyFormat\n+import com.twitter.util.Future\n+import org.jboss.netty.buffer.{ChannelBuffers, ChannelBuffer}\n+\n+trait Scripts { self: BaseClient =>\n+  val handleUnit: PartialFunction[Reply, Future[Unit]] = {\n+    case StatusReply(_) | EmptyBulkReply() => Future.Unit\n+  }\n+\n+  val handleLong: PartialFunction[Reply, Future[Long]] = {\n+    case IntegerReply(n) => Future.value(n)\n+  }\n+\n+  val handleBool: PartialFunction[Reply, Future[Boolean]] = {\n+    case IntegerReply(n)  => Future.value(n == 1)\n+    case EmptyBulkReply() => Future.False\n+    case StatusReply(_)   => Future.True\n+  }\n+\n+  val handleBuffer: PartialFunction[Reply, Future[ChannelBuffer]] = {\n+    case BulkReply(message) => Future.value(message)\n+    case EmptyBulkReply() => Future.value(ChannelBuffers.EMPTY_BUFFER)\n+  }\n+\n+  val handleBuffers: PartialFunction[Reply, Future[Seq[ChannelBuffer]]] = {\n+    case MBulkReply(messages) => Future.value(ReplyFormat.toChannelBuffers(messages))\n+    case EmptyMBulkReply()    => Future.Nil\n+  }\n+\n+  def retryOnNoScript[T](retry: () => T): PartialFunction[Reply, T] = {\n+    // NOTE: we cannot make retry call-by-value.\n+    // if we make retry call-by-value, the evalXXX() request will happen immediately\n+    // when we construct the partial function, thus evalXXX() will be executed before evalShaXXX().\n+    // NOTE: so we need call-by-need. but if we use \"retry: => T\",\n+    // when we debug the program, the debugger will force evaluate retry EVERY TIME\n+    // when retryOnNoScript is the current frame, resulting in confusion,\n+    // especially when retry has side-effects.\n+    // so we make retry: () => T an explicity function to prevent the debugger working too eagerly\n+    case ErrorReply(message) if message.startsWith(\"NOSCRIPT\") =>\n+      retry()\n+  }\n+\n+  // NOTE: because there is no easy way of telling the return type of the passed script,","path":"finagle-redis/src/main/scala/com/twitter/finagle/redis/ScriptCommands.scala","position":46,"original_position":46,"commit_id":"1d36bd1b797351b98cca20ec34e808963195d120","original_commit_id":"1d36bd1b797351b98cca20ec34e808963195d120","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":"rm NOTE","created_at":"2015-05-17T14:00:35Z","updated_at":"2015-05-17T14:00:35Z","html_url":"https://github.com/twitter/finagle/pull/381#discussion_r30470625","pull_request_url":"https://api.github.com/repos/twitter/finagle/pulls/381","_links":{"self":{"href":"https://api.github.com/repos/twitter/finagle/pulls/comments/30470625"},"html":{"href":"https://github.com/twitter/finagle/pull/381#discussion_r30470625"},"pull_request":{"href":"https://api.github.com/repos/twitter/finagle/pulls/381"}}},"pull_request":{"url":"https://api.github.com/repos/twitter/finagle/pulls/381","id":35350438,"html_url":"https://github.com/twitter/finagle/pull/381","diff_url":"https://github.com/twitter/finagle/pull/381.diff","patch_url":"https://github.com/twitter/finagle/pull/381.patch","issue_url":"https://api.github.com/repos/twitter/finagle/issues/381","number":381,"state":"open","locked":false,"title":"add scripting feature to finagle-redis with integration tests.","user":{"login":"timxzl","id":3528953,"avatar_url":"https://avatars.githubusercontent.com/u/3528953?v=3","gravatar_id":"","url":"https://api.github.com/users/timxzl","html_url":"https://github.com/timxzl","followers_url":"https://api.github.com/users/timxzl/followers","following_url":"https://api.github.com/users/timxzl/following{/other_user}","gists_url":"https://api.github.com/users/timxzl/gists{/gist_id}","starred_url":"https://api.github.com/users/timxzl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timxzl/subscriptions","organizations_url":"https://api.github.com/users/timxzl/orgs","repos_url":"https://api.github.com/users/timxzl/repos","events_url":"https://api.github.com/users/timxzl/events{/privacy}","received_events_url":"https://api.github.com/users/timxzl/received_events","type":"User","site_admin":false},"body":"supported commands: EVAL, EVALSHA, SCRIPT EXISTS, SCRIPT FLUSH, SCRIPT LOAD.","created_at":"2015-05-13T17:25:54Z","updated_at":"2015-05-17T14:00:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8f652b6409e8f77130e30fe4d6822b1028b6b9f2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/twitter/finagle/pulls/381/commits","review_comments_url":"https://api.github.com/repos/twitter/finagle/pulls/381/comments","review_comment_url":"https://api.github.com/repos/twitter/finagle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/twitter/finagle/issues/381/comments","statuses_url":"https://api.github.com/repos/twitter/finagle/statuses/1d36bd1b797351b98cca20ec34e808963195d120","head":{"label":"timxzl:master","ref":"master","sha":"1d36bd1b797351b98cca20ec34e808963195d120","user":{"login":"timxzl","id":3528953,"avatar_url":"https://avatars.githubusercontent.com/u/3528953?v=3","gravatar_id":"","url":"https://api.github.com/users/timxzl","html_url":"https://github.com/timxzl","followers_url":"https://api.github.com/users/timxzl/followers","following_url":"https://api.github.com/users/timxzl/following{/other_user}","gists_url":"https://api.github.com/users/timxzl/gists{/gist_id}","starred_url":"https://api.github.com/users/timxzl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timxzl/subscriptions","organizations_url":"https://api.github.com/users/timxzl/orgs","repos_url":"https://api.github.com/users/timxzl/repos","events_url":"https://api.github.com/users/timxzl/events{/privacy}","received_events_url":"https://api.github.com/users/timxzl/received_events","type":"User","site_admin":false},"repo":{"id":35559265,"name":"finagle","full_name":"timxzl/finagle","owner":{"login":"timxzl","id":3528953,"avatar_url":"https://avatars.githubusercontent.com/u/3528953?v=3","gravatar_id":"","url":"https://api.github.com/users/timxzl","html_url":"https://github.com/timxzl","followers_url":"https://api.github.com/users/timxzl/followers","following_url":"https://api.github.com/users/timxzl/following{/other_user}","gists_url":"https://api.github.com/users/timxzl/gists{/gist_id}","starred_url":"https://api.github.com/users/timxzl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timxzl/subscriptions","organizations_url":"https://api.github.com/users/timxzl/orgs","repos_url":"https://api.github.com/users/timxzl/repos","events_url":"https://api.github.com/users/timxzl/events{/privacy}","received_events_url":"https://api.github.com/users/timxzl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/timxzl/finagle","description":"A fault tolerant, protocol-agnostic RPC system","fork":true,"url":"https://api.github.com/repos/timxzl/finagle","forks_url":"https://api.github.com/repos/timxzl/finagle/forks","keys_url":"https://api.github.com/repos/timxzl/finagle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/timxzl/finagle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/timxzl/finagle/teams","hooks_url":"https://api.github.com/repos/timxzl/finagle/hooks","issue_events_url":"https://api.github.com/repos/timxzl/finagle/issues/events{/number}","events_url":"https://api.github.com/repos/timxzl/finagle/events","assignees_url":"https://api.github.com/repos/timxzl/finagle/assignees{/user}","branches_url":"https://api.github.com/repos/timxzl/finagle/branches{/branch}","tags_url":"https://api.github.com/repos/timxzl/finagle/tags","blobs_url":"https://api.github.com/repos/timxzl/finagle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/timxzl/finagle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/timxzl/finagle/git/refs{/sha}","trees_url":"https://api.github.com/repos/timxzl/finagle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/timxzl/finagle/statuses/{sha}","languages_url":"https://api.github.com/repos/timxzl/finagle/languages","stargazers_url":"https://api.github.com/repos/timxzl/finagle/stargazers","contributors_url":"https://api.github.com/repos/timxzl/finagle/contributors","subscribers_url":"https://api.github.com/repos/timxzl/finagle/subscribers","subscription_url":"https://api.github.com/repos/timxzl/finagle/subscription","commits_url":"https://api.github.com/repos/timxzl/finagle/commits{/sha}","git_commits_url":"https://api.github.com/repos/timxzl/finagle/git/commits{/sha}","comments_url":"https://api.github.com/repos/timxzl/finagle/comments{/number}","issue_comment_url":"https://api.github.com/repos/timxzl/finagle/issues/comments{/number}","contents_url":"https://api.github.com/repos/timxzl/finagle/contents/{+path}","compare_url":"https://api.github.com/repos/timxzl/finagle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/timxzl/finagle/merges","archive_url":"https://api.github.com/repos/timxzl/finagle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/timxzl/finagle/downloads","issues_url":"https://api.github.com/repos/timxzl/finagle/issues{/number}","pulls_url":"https://api.github.com/repos/timxzl/finagle/pulls{/number}","milestones_url":"https://api.github.com/repos/timxzl/finagle/milestones{/number}","notifications_url":"https://api.github.com/repos/timxzl/finagle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/timxzl/finagle/labels{/name}","releases_url":"https://api.github.com/repos/timxzl/finagle/releases{/id}","created_at":"2015-05-13T16:06:06Z","updated_at":"2015-05-13T16:06:09Z","pushed_at":"2015-05-14T05:13:58Z","git_url":"git://github.com/timxzl/finagle.git","ssh_url":"git@github.com:timxzl/finagle.git","clone_url":"https://github.com/timxzl/finagle.git","svn_url":"https://github.com/timxzl/finagle","homepage":"http://twitter.github.io/finagle","size":28297,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"twitter:master","ref":"master","sha":"78909170b7cc97044481274e297805d770465110","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}","created_at":"2010-10-19T22:10:09Z","updated_at":"2015-05-16T05:58:28Z","pushed_at":"2015-05-14T05:14:00Z","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":36345,"stargazers_count":3438,"watchers_count":3438,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":652,"mirror_url":null,"open_issues_count":47,"forks":652,"open_issues":47,"watchers":3438,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/twitter/finagle/pulls/381"},"html":{"href":"https://github.com/twitter/finagle/pull/381"},"issue":{"href":"https://api.github.com/repos/twitter/finagle/issues/381"},"comments":{"href":"https://api.github.com/repos/twitter/finagle/issues/381/comments"},"review_comments":{"href":"https://api.github.com/repos/twitter/finagle/pulls/381/comments"},"review_comment":{"href":"https://api.github.com/repos/twitter/finagle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/twitter/finagle/pulls/381/commits"},"statuses":{"href":"https://api.github.com/repos/twitter/finagle/statuses/1d36bd1b797351b98cca20ec34e808963195d120"}}}}