{"action":"created","comment":{"url":"https://api.github.com/repos/bro/bro-plugins/pulls/comments/57228670","id":57228670,"diff_hunk":"@@ -9,18 +9,69 @@\n using namespace logging;\n using namespace writer;\n \n-KafkaWriter::KafkaWriter(WriterFrontend* frontend): WriterBackend(frontend), formatter(NULL), producer(NULL), topic(NULL)\n-{\n-    // TODO do we need this??\n-    topic_name.assign((const char*)BifConst::Kafka::topic_name->Bytes(),\n-        BifConst::Kafka::topic_name->Len());\n-}\n+KafkaWriter::KafkaWriter(WriterFrontend* frontend): WriterBackend(frontend), formatter(NULL), rd_producer(NULL)\n+{}\n \n KafkaWriter::~KafkaWriter()\n {}\n \n+string KafkaWriter::FindInTable(Val* table, string key_to_find)\n+{\n+    string err;\n+    IterCookie* c = table->AsTable()->InitForIteration();\n+    HashKey* k;\n+    TableEntryVal* v;\n+    while ((v = table->AsTable()->NextEntry(k, c))) {\n+\n+        // fetch the key and value\n+        ListVal* index = table->AsTableVal()->RecoverIndex(k);\n+        string key = index->Index(0)->AsString()->CheckString();\n+        string val = v->Value()->AsString()->CheckString();\n+\n+        if (key == key_to_find) {\n+            return val;\n+        }\n+\n+        // cleanup\n+        Unref(index);\n+        delete k;\n+    }","path":"kafka/src/KafkaWriter.cc","position":36,"original_position":36,"commit_id":"e90d9612a341874847277b71a21efba05348807d","original_commit_id":"e90d9612a341874847277b71a21efba05348807d","user":{"login":"nickwallen","id":2475409,"avatar_url":"https://avatars.githubusercontent.com/u/2475409?v=3","gravatar_id":"","url":"https://api.github.com/users/nickwallen","html_url":"https://github.com/nickwallen","followers_url":"https://api.github.com/users/nickwallen/followers","following_url":"https://api.github.com/users/nickwallen/following{/other_user}","gists_url":"https://api.github.com/users/nickwallen/gists{/gist_id}","starred_url":"https://api.github.com/users/nickwallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickwallen/subscriptions","organizations_url":"https://api.github.com/users/nickwallen/orgs","repos_url":"https://api.github.com/users/nickwallen/repos","events_url":"https://api.github.com/users/nickwallen/events{/privacy}","received_events_url":"https://api.github.com/users/nickwallen/received_events","type":"User","site_admin":false},"body":"Is there a better way to implement `FindInTable`?  I am not at all familiar with this TableVal API.","created_at":"2016-03-23T20:14:45Z","updated_at":"2016-03-23T20:14:45Z","html_url":"https://github.com/bro/bro-plugins/pull/22#discussion_r57228670","pull_request_url":"https://api.github.com/repos/bro/bro-plugins/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/bro/bro-plugins/pulls/comments/57228670"},"html":{"href":"https://github.com/bro/bro-plugins/pull/22#discussion_r57228670"},"pull_request":{"href":"https://api.github.com/repos/bro/bro-plugins/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/bro/bro-plugins/pulls/22","id":63945325,"html_url":"https://github.com/bro/bro-plugins/pull/22","diff_url":"https://github.com/bro/bro-plugins/pull/22.diff","patch_url":"https://github.com/bro/bro-plugins/pull/22.patch","issue_url":"https://api.github.com/repos/bro/bro-plugins/issues/22","number":22,"state":"open","locked":false,"title":"BIT-1559 Bro-Plugins Send each log stream to different kafka topic","user":{"login":"nickwallen","id":2475409,"avatar_url":"https://avatars.githubusercontent.com/u/2475409?v=3","gravatar_id":"","url":"https://api.github.com/users/nickwallen","html_url":"https://github.com/nickwallen","followers_url":"https://api.github.com/users/nickwallen/followers","following_url":"https://api.github.com/users/nickwallen/following{/other_user}","gists_url":"https://api.github.com/users/nickwallen/gists{/gist_id}","starred_url":"https://api.github.com/users/nickwallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickwallen/subscriptions","organizations_url":"https://api.github.com/users/nickwallen/orgs","repos_url":"https://api.github.com/users/nickwallen/repos","events_url":"https://api.github.com/users/nickwallen/events{/privacy}","received_events_url":"https://api.github.com/users/nickwallen/received_events","type":"User","site_admin":false},"body":"The current Kafka log writer sends all log streams (Conn, Http, Dns, etc) to the same Kafka topic.  This change allows the user to configure a separate topic for each log stream.  \r\n\r\n```\r\n redef Kafka::topic_conf = table(\r\n      [\"Conn::LOG\"] = \"bro_conn_topic\",\r\n      [\"HTTP::LOG\"] = \"bro_http_topic\",\r\n      [\"DNS::LOG\"] = \"bro_dns_topic\",\r\n      [\"*\"] = \"bro_default_topic\"\r\n);\r\n```\r\n\r\nAs can be seen in the example, if a specific stream-to-topic definition is not provided, the code will use the default (wildcard) topic indicated by an asterisk (*).  If no topic definition can be found the code will raise an error.","created_at":"2016-03-23T20:12:56Z","updated_at":"2016-03-23T20:14:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ca5fb270f3cae70092998974c0cbe6d126bf01ca","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bro/bro-plugins/pulls/22/commits","review_comments_url":"https://api.github.com/repos/bro/bro-plugins/pulls/22/comments","review_comment_url":"https://api.github.com/repos/bro/bro-plugins/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bro/bro-plugins/issues/22/comments","statuses_url":"https://api.github.com/repos/bro/bro-plugins/statuses/e90d9612a341874847277b71a21efba05348807d","head":{"label":"nickwallen:support-many-kafka-topics","ref":"support-many-kafka-topics","sha":"e90d9612a341874847277b71a21efba05348807d","user":{"login":"nickwallen","id":2475409,"avatar_url":"https://avatars.githubusercontent.com/u/2475409?v=3","gravatar_id":"","url":"https://api.github.com/users/nickwallen","html_url":"https://github.com/nickwallen","followers_url":"https://api.github.com/users/nickwallen/followers","following_url":"https://api.github.com/users/nickwallen/following{/other_user}","gists_url":"https://api.github.com/users/nickwallen/gists{/gist_id}","starred_url":"https://api.github.com/users/nickwallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickwallen/subscriptions","organizations_url":"https://api.github.com/users/nickwallen/orgs","repos_url":"https://api.github.com/users/nickwallen/repos","events_url":"https://api.github.com/users/nickwallen/events{/privacy}","received_events_url":"https://api.github.com/users/nickwallen/received_events","type":"User","site_admin":false},"repo":{"id":51787873,"name":"bro-plugins","full_name":"nickwallen/bro-plugins","owner":{"login":"nickwallen","id":2475409,"avatar_url":"https://avatars.githubusercontent.com/u/2475409?v=3","gravatar_id":"","url":"https://api.github.com/users/nickwallen","html_url":"https://github.com/nickwallen","followers_url":"https://api.github.com/users/nickwallen/followers","following_url":"https://api.github.com/users/nickwallen/following{/other_user}","gists_url":"https://api.github.com/users/nickwallen/gists{/gist_id}","starred_url":"https://api.github.com/users/nickwallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickwallen/subscriptions","organizations_url":"https://api.github.com/users/nickwallen/orgs","repos_url":"https://api.github.com/users/nickwallen/repos","events_url":"https://api.github.com/users/nickwallen/events{/privacy}","received_events_url":"https://api.github.com/users/nickwallen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nickwallen/bro-plugins","description":"Plugins for Bro","fork":true,"url":"https://api.github.com/repos/nickwallen/bro-plugins","forks_url":"https://api.github.com/repos/nickwallen/bro-plugins/forks","keys_url":"https://api.github.com/repos/nickwallen/bro-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nickwallen/bro-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nickwallen/bro-plugins/teams","hooks_url":"https://api.github.com/repos/nickwallen/bro-plugins/hooks","issue_events_url":"https://api.github.com/repos/nickwallen/bro-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/nickwallen/bro-plugins/events","assignees_url":"https://api.github.com/repos/nickwallen/bro-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/nickwallen/bro-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/nickwallen/bro-plugins/tags","blobs_url":"https://api.github.com/repos/nickwallen/bro-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nickwallen/bro-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nickwallen/bro-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/nickwallen/bro-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nickwallen/bro-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/nickwallen/bro-plugins/languages","stargazers_url":"https://api.github.com/repos/nickwallen/bro-plugins/stargazers","contributors_url":"https://api.github.com/repos/nickwallen/bro-plugins/contributors","subscribers_url":"https://api.github.com/repos/nickwallen/bro-plugins/subscribers","subscription_url":"https://api.github.com/repos/nickwallen/bro-plugins/subscription","commits_url":"https://api.github.com/repos/nickwallen/bro-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/nickwallen/bro-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/nickwallen/bro-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/nickwallen/bro-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/nickwallen/bro-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/nickwallen/bro-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nickwallen/bro-plugins/merges","archive_url":"https://api.github.com/repos/nickwallen/bro-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nickwallen/bro-plugins/downloads","issues_url":"https://api.github.com/repos/nickwallen/bro-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/nickwallen/bro-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/nickwallen/bro-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/nickwallen/bro-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nickwallen/bro-plugins/labels{/name}","releases_url":"https://api.github.com/repos/nickwallen/bro-plugins/releases{/id}","deployments_url":"https://api.github.com/repos/nickwallen/bro-plugins/deployments","created_at":"2016-02-15T21:43:57Z","updated_at":"2016-02-15T21:43:59Z","pushed_at":"2016-03-23T20:05:56Z","git_url":"git://github.com/nickwallen/bro-plugins.git","ssh_url":"git@github.com:nickwallen/bro-plugins.git","clone_url":"https://github.com/nickwallen/bro-plugins.git","svn_url":"https://github.com/nickwallen/bro-plugins","homepage":null,"size":788,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"bro:master","ref":"master","sha":"ab61be0c4f128c976f72dfa5a09a87cd842f387a","user":{"login":"bro","id":1194067,"avatar_url":"https://avatars.githubusercontent.com/u/1194067?v=3","gravatar_id":"","url":"https://api.github.com/users/bro","html_url":"https://github.com/bro","followers_url":"https://api.github.com/users/bro/followers","following_url":"https://api.github.com/users/bro/following{/other_user}","gists_url":"https://api.github.com/users/bro/gists{/gist_id}","starred_url":"https://api.github.com/users/bro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bro/subscriptions","organizations_url":"https://api.github.com/users/bro/orgs","repos_url":"https://api.github.com/users/bro/repos","events_url":"https://api.github.com/users/bro/events{/privacy}","received_events_url":"https://api.github.com/users/bro/received_events","type":"Organization","site_admin":false},"repo":{"id":23641392,"name":"bro-plugins","full_name":"bro/bro-plugins","owner":{"login":"bro","id":1194067,"avatar_url":"https://avatars.githubusercontent.com/u/1194067?v=3","gravatar_id":"","url":"https://api.github.com/users/bro","html_url":"https://github.com/bro","followers_url":"https://api.github.com/users/bro/followers","following_url":"https://api.github.com/users/bro/following{/other_user}","gists_url":"https://api.github.com/users/bro/gists{/gist_id}","starred_url":"https://api.github.com/users/bro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bro/subscriptions","organizations_url":"https://api.github.com/users/bro/orgs","repos_url":"https://api.github.com/users/bro/repos","events_url":"https://api.github.com/users/bro/events{/privacy}","received_events_url":"https://api.github.com/users/bro/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bro/bro-plugins","description":"Plugins for Bro","fork":false,"url":"https://api.github.com/repos/bro/bro-plugins","forks_url":"https://api.github.com/repos/bro/bro-plugins/forks","keys_url":"https://api.github.com/repos/bro/bro-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bro/bro-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bro/bro-plugins/teams","hooks_url":"https://api.github.com/repos/bro/bro-plugins/hooks","issue_events_url":"https://api.github.com/repos/bro/bro-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/bro/bro-plugins/events","assignees_url":"https://api.github.com/repos/bro/bro-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/bro/bro-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/bro/bro-plugins/tags","blobs_url":"https://api.github.com/repos/bro/bro-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bro/bro-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bro/bro-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/bro/bro-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bro/bro-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/bro/bro-plugins/languages","stargazers_url":"https://api.github.com/repos/bro/bro-plugins/stargazers","contributors_url":"https://api.github.com/repos/bro/bro-plugins/contributors","subscribers_url":"https://api.github.com/repos/bro/bro-plugins/subscribers","subscription_url":"https://api.github.com/repos/bro/bro-plugins/subscription","commits_url":"https://api.github.com/repos/bro/bro-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/bro/bro-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/bro/bro-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/bro/bro-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/bro/bro-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/bro/bro-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bro/bro-plugins/merges","archive_url":"https://api.github.com/repos/bro/bro-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bro/bro-plugins/downloads","issues_url":"https://api.github.com/repos/bro/bro-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/bro/bro-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/bro/bro-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/bro/bro-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bro/bro-plugins/labels{/name}","releases_url":"https://api.github.com/repos/bro/bro-plugins/releases{/id}","deployments_url":"https://api.github.com/repos/bro/bro-plugins/deployments","created_at":"2014-09-03T23:30:35Z","updated_at":"2016-03-22T14:38:51Z","pushed_at":"2016-03-23T20:12:57Z","git_url":"git://github.com/bro/bro-plugins.git","ssh_url":"git@github.com:bro/bro-plugins.git","clone_url":"https://github.com/bro/bro-plugins.git","svn_url":"https://github.com/bro/bro-plugins","homepage":null,"size":785,"stargazers_count":25,"watchers_count":25,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":7,"forks":24,"open_issues":7,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bro/bro-plugins/pulls/22"},"html":{"href":"https://github.com/bro/bro-plugins/pull/22"},"issue":{"href":"https://api.github.com/repos/bro/bro-plugins/issues/22"},"comments":{"href":"https://api.github.com/repos/bro/bro-plugins/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/bro/bro-plugins/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/bro/bro-plugins/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bro/bro-plugins/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/bro/bro-plugins/statuses/e90d9612a341874847277b71a21efba05348807d"}}}}