{"action":"created","comment":{"url":"https://api.github.com/repos/gauge-buddy/playground/pulls/comments/70181367","id":70181367,"diff_hunk":"@@ -1,29 +1,29 @@\n import java.util.Properties\n-import org.apache.kafka.clients.producer.{ProducerRecord, KafkaProducer => ApacheKafkaProducer}\n+import org.apache.kafka.clients.producer.{KafkaProducer => ApacheKafkaProducer, RecordMetadata, Callback, ProducerRecord}\n+import scalaz.{-\\/, \\/-, \\/}\n import scalaz.concurrent.Task\n \n class KafkaProducer extends Producer {\n \n-  override def send[A](content: A)(implicit serializer: Serializer[A]): Task[Unit] = {\n-    val properties = getProperties\n-    val message = serializer.serialize(content)\n+  override def send[K, V](key: K, content: V)(implicit config: KafkaProducerConfig): Task[Unit] = {\n+    val props = new Properties()\n+    props.put(\"bootstrap.servers\", config.servers)\n+    props.put(\"key.serializer\", config.keySerializer.runtimeClass)\n+    props.put(\"value.serializer\", config.valueSerializer.runtimeClass)\n+    props.put(\"partitioner.class\", config.partitioner.runtimeClass)\n \n-    val producer = new ApacheKafkaProducer[String, String](properties)\n+    val producer = new ApacheKafkaProducer[K, V](props)\n     val t = System.currentTimeMillis()\n-    val data = new ProducerRecord[String, String](\"topic3\", 0, t, \"test\", message)\n-    val futureRecord = producer.send(data)\n+    val data = new ProducerRecord[K, V](config.topic, 0, t, key, content)\n \n     //TODO: specify timeout -> load it from the app config\n-    Task { futureRecord.get() }\n-  }\n-\n-  def getProperties: Properties = {\n-    //TODO: load properties from application.conf using typesafe config\n-    val props = new Properties()\n-    props.put(\"bootstrap.servers\", \"192.168.1.11:32768\")\n-    props.put(\"key.serializer\", \"org.apache.kafka.common.serialization.StringSerializer\")\n-    props.put(\"value.serializer\", \"org.apache.kafka.common.serialization.StringSerializer\")\n-    props.put(\"partitioner.class\", \"org.apache.kafka.clients.producer.internals.DefaultPartitioner\")\n-    props\n+    Task.async(k => producer.send(data, new Callback {\n+      override def onCompletion(recordMetadata: RecordMetadata, e: Exception): Unit = {\n+        e match {","path":"KafkaDemo/src/main/scala/KafkaProducer.scala","position":null,"original_position":40,"commit_id":"f41231b52f3377f223df4e3374bd34b7ccf00f14","original_commit_id":"f41231b52f3377f223df4e3374bd34b7ccf00f14","user":{"login":"theocat","id":5885168,"avatar_url":"https://avatars.githubusercontent.com/u/5885168?v=3","gravatar_id":"","url":"https://api.github.com/users/theocat","html_url":"https://github.com/theocat","followers_url":"https://api.github.com/users/theocat/followers","following_url":"https://api.github.com/users/theocat/following{/other_user}","gists_url":"https://api.github.com/users/theocat/gists{/gist_id}","starred_url":"https://api.github.com/users/theocat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theocat/subscriptions","organizations_url":"https://api.github.com/users/theocat/orgs","repos_url":"https://api.github.com/users/theocat/repos","events_url":"https://api.github.com/users/theocat/events{/privacy}","received_events_url":"https://api.github.com/users/theocat/received_events","type":"User","site_admin":false},"body":"you have a somewhat clunky callback behaviour here. metadata is not null when the callback is valid. exception is not null, when callback indicates an error. I'd suggest you to do `Option(metadata) -> Option(exception)` and then match `(Some(m), None) and (None, Some(e))`","created_at":"2016-07-10T12:45:18Z","updated_at":"2016-07-10T12:45:18Z","html_url":"https://github.com/gauge-buddy/playground/pull/1#discussion_r70181367","pull_request_url":"https://api.github.com/repos/gauge-buddy/playground/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/gauge-buddy/playground/pulls/comments/70181367"},"html":{"href":"https://github.com/gauge-buddy/playground/pull/1#discussion_r70181367"},"pull_request":{"href":"https://api.github.com/repos/gauge-buddy/playground/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/gauge-buddy/playground/pulls/1","id":76859587,"html_url":"https://github.com/gauge-buddy/playground/pull/1","diff_url":"https://github.com/gauge-buddy/playground/pull/1.diff","patch_url":"https://github.com/gauge-buddy/playground/pull/1.patch","issue_url":"https://api.github.com/repos/gauge-buddy/playground/issues/1","number":1,"state":"open","locked":false,"title":"Kafka producer: first attempt","user":{"login":"stormy-ua","id":5732047,"avatar_url":"https://avatars.githubusercontent.com/u/5732047?v=3","gravatar_id":"","url":"https://api.github.com/users/stormy-ua","html_url":"https://github.com/stormy-ua","followers_url":"https://api.github.com/users/stormy-ua/followers","following_url":"https://api.github.com/users/stormy-ua/following{/other_user}","gists_url":"https://api.github.com/users/stormy-ua/gists{/gist_id}","starred_url":"https://api.github.com/users/stormy-ua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stormy-ua/subscriptions","organizations_url":"https://api.github.com/users/stormy-ua/orgs","repos_url":"https://api.github.com/users/stormy-ua/repos","events_url":"https://api.github.com/users/stormy-ua/events{/privacy}","received_events_url":"https://api.github.com/users/stormy-ua/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-09T23:16:03Z","updated_at":"2016-07-10T12:45:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"efb38a9e89a21dbc2d9065a3e79c1849175523a5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/gauge-buddy/playground/pulls/1/commits","review_comments_url":"https://api.github.com/repos/gauge-buddy/playground/pulls/1/comments","review_comment_url":"https://api.github.com/repos/gauge-buddy/playground/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gauge-buddy/playground/issues/1/comments","statuses_url":"https://api.github.com/repos/gauge-buddy/playground/statuses/f41231b52f3377f223df4e3374bd34b7ccf00f14","head":{"label":"stormy-ua:kafka-producer","ref":"kafka-producer","sha":"f41231b52f3377f223df4e3374bd34b7ccf00f14","user":{"login":"stormy-ua","id":5732047,"avatar_url":"https://avatars.githubusercontent.com/u/5732047?v=3","gravatar_id":"","url":"https://api.github.com/users/stormy-ua","html_url":"https://github.com/stormy-ua","followers_url":"https://api.github.com/users/stormy-ua/followers","following_url":"https://api.github.com/users/stormy-ua/following{/other_user}","gists_url":"https://api.github.com/users/stormy-ua/gists{/gist_id}","starred_url":"https://api.github.com/users/stormy-ua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stormy-ua/subscriptions","organizations_url":"https://api.github.com/users/stormy-ua/orgs","repos_url":"https://api.github.com/users/stormy-ua/repos","events_url":"https://api.github.com/users/stormy-ua/events{/privacy}","received_events_url":"https://api.github.com/users/stormy-ua/received_events","type":"User","site_admin":false},"repo":{"id":62969985,"name":"playground","full_name":"stormy-ua/playground","owner":{"login":"stormy-ua","id":5732047,"avatar_url":"https://avatars.githubusercontent.com/u/5732047?v=3","gravatar_id":"","url":"https://api.github.com/users/stormy-ua","html_url":"https://github.com/stormy-ua","followers_url":"https://api.github.com/users/stormy-ua/followers","following_url":"https://api.github.com/users/stormy-ua/following{/other_user}","gists_url":"https://api.github.com/users/stormy-ua/gists{/gist_id}","starred_url":"https://api.github.com/users/stormy-ua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stormy-ua/subscriptions","organizations_url":"https://api.github.com/users/stormy-ua/orgs","repos_url":"https://api.github.com/users/stormy-ua/repos","events_url":"https://api.github.com/users/stormy-ua/events{/privacy}","received_events_url":"https://api.github.com/users/stormy-ua/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/stormy-ua/playground","description":null,"fork":true,"url":"https://api.github.com/repos/stormy-ua/playground","forks_url":"https://api.github.com/repos/stormy-ua/playground/forks","keys_url":"https://api.github.com/repos/stormy-ua/playground/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stormy-ua/playground/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stormy-ua/playground/teams","hooks_url":"https://api.github.com/repos/stormy-ua/playground/hooks","issue_events_url":"https://api.github.com/repos/stormy-ua/playground/issues/events{/number}","events_url":"https://api.github.com/repos/stormy-ua/playground/events","assignees_url":"https://api.github.com/repos/stormy-ua/playground/assignees{/user}","branches_url":"https://api.github.com/repos/stormy-ua/playground/branches{/branch}","tags_url":"https://api.github.com/repos/stormy-ua/playground/tags","blobs_url":"https://api.github.com/repos/stormy-ua/playground/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stormy-ua/playground/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stormy-ua/playground/git/refs{/sha}","trees_url":"https://api.github.com/repos/stormy-ua/playground/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stormy-ua/playground/statuses/{sha}","languages_url":"https://api.github.com/repos/stormy-ua/playground/languages","stargazers_url":"https://api.github.com/repos/stormy-ua/playground/stargazers","contributors_url":"https://api.github.com/repos/stormy-ua/playground/contributors","subscribers_url":"https://api.github.com/repos/stormy-ua/playground/subscribers","subscription_url":"https://api.github.com/repos/stormy-ua/playground/subscription","commits_url":"https://api.github.com/repos/stormy-ua/playground/commits{/sha}","git_commits_url":"https://api.github.com/repos/stormy-ua/playground/git/commits{/sha}","comments_url":"https://api.github.com/repos/stormy-ua/playground/comments{/number}","issue_comment_url":"https://api.github.com/repos/stormy-ua/playground/issues/comments{/number}","contents_url":"https://api.github.com/repos/stormy-ua/playground/contents/{+path}","compare_url":"https://api.github.com/repos/stormy-ua/playground/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stormy-ua/playground/merges","archive_url":"https://api.github.com/repos/stormy-ua/playground/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stormy-ua/playground/downloads","issues_url":"https://api.github.com/repos/stormy-ua/playground/issues{/number}","pulls_url":"https://api.github.com/repos/stormy-ua/playground/pulls{/number}","milestones_url":"https://api.github.com/repos/stormy-ua/playground/milestones{/number}","notifications_url":"https://api.github.com/repos/stormy-ua/playground/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stormy-ua/playground/labels{/name}","releases_url":"https://api.github.com/repos/stormy-ua/playground/releases{/id}","deployments_url":"https://api.github.com/repos/stormy-ua/playground/deployments","created_at":"2016-07-09T21:31:47Z","updated_at":"2016-07-09T21:31:49Z","pushed_at":"2016-07-10T02:52:56Z","git_url":"git://github.com/stormy-ua/playground.git","ssh_url":"git@github.com:stormy-ua/playground.git","clone_url":"https://github.com/stormy-ua/playground.git","svn_url":"https://github.com/stormy-ua/playground","homepage":null,"size":6,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gauge-buddy:master","ref":"master","sha":"93a1ed82ad637b1a2f06c8538b58ba5a502fd672","user":{"login":"gauge-buddy","id":20232964,"avatar_url":"https://avatars.githubusercontent.com/u/20232964?v=3","gravatar_id":"","url":"https://api.github.com/users/gauge-buddy","html_url":"https://github.com/gauge-buddy","followers_url":"https://api.github.com/users/gauge-buddy/followers","following_url":"https://api.github.com/users/gauge-buddy/following{/other_user}","gists_url":"https://api.github.com/users/gauge-buddy/gists{/gist_id}","starred_url":"https://api.github.com/users/gauge-buddy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gauge-buddy/subscriptions","organizations_url":"https://api.github.com/users/gauge-buddy/orgs","repos_url":"https://api.github.com/users/gauge-buddy/repos","events_url":"https://api.github.com/users/gauge-buddy/events{/privacy}","received_events_url":"https://api.github.com/users/gauge-buddy/received_events","type":"Organization","site_admin":false},"repo":{"id":62583825,"name":"playground","full_name":"gauge-buddy/playground","owner":{"login":"gauge-buddy","id":20232964,"avatar_url":"https://avatars.githubusercontent.com/u/20232964?v=3","gravatar_id":"","url":"https://api.github.com/users/gauge-buddy","html_url":"https://github.com/gauge-buddy","followers_url":"https://api.github.com/users/gauge-buddy/followers","following_url":"https://api.github.com/users/gauge-buddy/following{/other_user}","gists_url":"https://api.github.com/users/gauge-buddy/gists{/gist_id}","starred_url":"https://api.github.com/users/gauge-buddy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gauge-buddy/subscriptions","organizations_url":"https://api.github.com/users/gauge-buddy/orgs","repos_url":"https://api.github.com/users/gauge-buddy/repos","events_url":"https://api.github.com/users/gauge-buddy/events{/privacy}","received_events_url":"https://api.github.com/users/gauge-buddy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gauge-buddy/playground","description":null,"fork":false,"url":"https://api.github.com/repos/gauge-buddy/playground","forks_url":"https://api.github.com/repos/gauge-buddy/playground/forks","keys_url":"https://api.github.com/repos/gauge-buddy/playground/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gauge-buddy/playground/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gauge-buddy/playground/teams","hooks_url":"https://api.github.com/repos/gauge-buddy/playground/hooks","issue_events_url":"https://api.github.com/repos/gauge-buddy/playground/issues/events{/number}","events_url":"https://api.github.com/repos/gauge-buddy/playground/events","assignees_url":"https://api.github.com/repos/gauge-buddy/playground/assignees{/user}","branches_url":"https://api.github.com/repos/gauge-buddy/playground/branches{/branch}","tags_url":"https://api.github.com/repos/gauge-buddy/playground/tags","blobs_url":"https://api.github.com/repos/gauge-buddy/playground/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gauge-buddy/playground/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gauge-buddy/playground/git/refs{/sha}","trees_url":"https://api.github.com/repos/gauge-buddy/playground/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gauge-buddy/playground/statuses/{sha}","languages_url":"https://api.github.com/repos/gauge-buddy/playground/languages","stargazers_url":"https://api.github.com/repos/gauge-buddy/playground/stargazers","contributors_url":"https://api.github.com/repos/gauge-buddy/playground/contributors","subscribers_url":"https://api.github.com/repos/gauge-buddy/playground/subscribers","subscription_url":"https://api.github.com/repos/gauge-buddy/playground/subscription","commits_url":"https://api.github.com/repos/gauge-buddy/playground/commits{/sha}","git_commits_url":"https://api.github.com/repos/gauge-buddy/playground/git/commits{/sha}","comments_url":"https://api.github.com/repos/gauge-buddy/playground/comments{/number}","issue_comment_url":"https://api.github.com/repos/gauge-buddy/playground/issues/comments{/number}","contents_url":"https://api.github.com/repos/gauge-buddy/playground/contents/{+path}","compare_url":"https://api.github.com/repos/gauge-buddy/playground/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gauge-buddy/playground/merges","archive_url":"https://api.github.com/repos/gauge-buddy/playground/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gauge-buddy/playground/downloads","issues_url":"https://api.github.com/repos/gauge-buddy/playground/issues{/number}","pulls_url":"https://api.github.com/repos/gauge-buddy/playground/pulls{/number}","milestones_url":"https://api.github.com/repos/gauge-buddy/playground/milestones{/number}","notifications_url":"https://api.github.com/repos/gauge-buddy/playground/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gauge-buddy/playground/labels{/name}","releases_url":"https://api.github.com/repos/gauge-buddy/playground/releases{/id}","deployments_url":"https://api.github.com/repos/gauge-buddy/playground/deployments","created_at":"2016-07-04T19:28:51Z","updated_at":"2016-07-04T19:38:38Z","pushed_at":"2016-07-10T02:52:56Z","git_url":"git://github.com/gauge-buddy/playground.git","ssh_url":"git@github.com:gauge-buddy/playground.git","clone_url":"https://github.com/gauge-buddy/playground.git","svn_url":"https://github.com/gauge-buddy/playground","homepage":null,"size":2,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gauge-buddy/playground/pulls/1"},"html":{"href":"https://github.com/gauge-buddy/playground/pull/1"},"issue":{"href":"https://api.github.com/repos/gauge-buddy/playground/issues/1"},"comments":{"href":"https://api.github.com/repos/gauge-buddy/playground/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/gauge-buddy/playground/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/gauge-buddy/playground/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gauge-buddy/playground/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/gauge-buddy/playground/statuses/f41231b52f3377f223df4e3374bd34b7ccf00f14"}}}}
{"actor":{"display_login":"theocat"}}