{"action":"created","comment":{"url":"https://api.github.com/repos/m3db/tally-cpp/pulls/comments/202151462","pull_request_review_id":136794519,"id":202151462,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMjE1MTQ2Mg==","diff_hunk":"@@ -0,0 +1,106 @@\n+// Copyright (c) 2018 Uber Technologies, Inc.\n+//\n+// Permission is hereby granted, free of charge, to any person obtaining a copy\n+// of this software and associated documentation files (the \"Software\"), to deal\n+// in the Software without restriction, including without limitation the rights\n+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+// copies of the Software, and to permit persons to whom the Software is\n+// furnished to do so, subject to the following conditions:\n+//\n+// The above copyright notice and this permission notice shall be included in\n+// all copies or substantial portions of the Software.\n+//\n+// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+// THE SOFTWARE.\n+\n+#pragma once\n+\n+#include <iostream>\n+#include <memory>\n+#include <mutex>\n+#include <string>\n+\n+#include \"thrift/protocol/TCompactProtocol.h\"\n+#include \"thrift/server/TSimpleServer.h\"\n+#include \"thrift/transport/TBufferTransports.h\"\n+#include \"thrift/transport/TServerSocket.h\"\n+\n+#include \"m3/thrift/M3.h\"\n+#include \"m3/udp_transport.h\"\n+\n+using apache::thrift::TProcessor;\n+using apache::thrift::protocol::TCompactProtocolFactory;\n+using apache::thrift::protocol::TProtocolFactory;\n+using apache::thrift::transport::TTransportException;\n+\n+class MockServer {\n+ public:\n+  MockServer(const std::string& host, uint16_t port) : stopped_(false) {\n+    handler_ =\n+        apache::thrift::stdcxx::shared_ptr<MockHandler>(new MockHandler());\n+    processor_ = apache::thrift::stdcxx::shared_ptr<TProcessor>(\n+        new tally::m3::thrift::M3Processor(handler_));\n+    transport_ = apache::thrift::stdcxx::shared_ptr<tally::m3::TUDPTransport>(\n+        new tally::m3::TUDPTransport(\n+            host, port, tally::m3::TUDPTransport::Kind::Server, 1440));\n+    transport_->open();\n+  }\n+\n+  ~MockServer() {\n+    std::lock_guard<std::mutex> lock(mutex_);\n+    if (!stopped_) {\n+      stop();\n+    }\n+  }\n+\n+  void serve() {\n+    apache::thrift::stdcxx::shared_ptr<TProtocolFactory> protocolFactory(\n+        new TCompactProtocolFactory());\n+    auto protocol = protocolFactory->getProtocol(transport_);\n+\n+    while (true) {\n+      {\n+        std::lock_guard<std::mutex> lock(mutex_);\n+        if (stopped_) {\n+          return;\n+        }\n+      }\n+\n+      try {\n+        processor_->process(protocol, protocol, NULL);\n+      } catch (const TTransportException& e) {\n+        std::lock_guard<std::mutex> lock(mutex_);\n+        if (stopped_) {\n+          return;\n+        }\n+        std::cerr << \"Encountered error processing M3 metrics: \" << e.what()\n+                  << std::endl;\n+      }\n+    }\n+  }\n+\n+  void stop() {\n+    std::lock_guard<std::mutex> lock(mutex_);\n+    stopped_ = true;\n+    transport_->close();\n+  }\n+\n+  bool isEmpty() { return handler_->isEmpty(); }\n+\n+  tally::m3::thrift::MetricBatch getBatch() { return handler_->getBatch(); }\n+\n+  uint16_t port() { return transport_->port(); }\n+\n+ private:\n+  apache::thrift::stdcxx::shared_ptr<TProcessor> processor_;\n+  apache::thrift::stdcxx::shared_ptr<tally::m3::TUDPTransport> transport_;\n+  apache::thrift::stdcxx::shared_ptr<MockHandler> handler_;","path":"m3/tests/mock_server.h","position":102,"original_position":102,"commit_id":"fc40db747b2aac5543307d337969121ade209b6f","original_commit_id":"789089eeddb86e1f6b190b03aaeb12834a94a8e8","user":{"login":"jeromefroe","id":7217598,"node_id":"MDQ6VXNlcjcyMTc1OTg=","avatar_url":"https://avatars1.githubusercontent.com/u/7217598?v=4","gravatar_id":"","url":"https://api.github.com/users/jeromefroe","html_url":"https://github.com/jeromefroe","followers_url":"https://api.github.com/users/jeromefroe/followers","following_url":"https://api.github.com/users/jeromefroe/following{/other_user}","gists_url":"https://api.github.com/users/jeromefroe/gists{/gist_id}","starred_url":"https://api.github.com/users/jeromefroe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeromefroe/subscriptions","organizations_url":"https://api.github.com/users/jeromefroe/orgs","repos_url":"https://api.github.com/users/jeromefroe/repos","events_url":"https://api.github.com/users/jeromefroe/events{/privacy}","received_events_url":"https://api.github.com/users/jeromefroe/received_events","type":"User","site_admin":false},"body":"Yea, it's just for testing.","created_at":"2018-07-12T19:24:43Z","updated_at":"2018-07-12T19:24:43Z","html_url":"https://github.com/m3db/tally-cpp/pull/1#discussion_r202151462","pull_request_url":"https://api.github.com/repos/m3db/tally-cpp/pulls/1","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/m3db/tally-cpp/pulls/comments/202151462"},"html":{"href":"https://github.com/m3db/tally-cpp/pull/1#discussion_r202151462"},"pull_request":{"href":"https://api.github.com/repos/m3db/tally-cpp/pulls/1"}},"in_reply_to_id":202140535},"pull_request":{"url":"https://api.github.com/repos/m3db/tally-cpp/pulls/1","id":200434834,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwNDM0ODM0","html_url":"https://github.com/m3db/tally-cpp/pull/1","diff_url":"https://github.com/m3db/tally-cpp/pull/1.diff","patch_url":"https://github.com/m3db/tally-cpp/pull/1.patch","issue_url":"https://api.github.com/repos/m3db/tally-cpp/issues/1","number":1,"state":"open","locked":false,"title":"Add initial implementation of tally client","user":{"login":"jeromefroe","id":7217598,"node_id":"MDQ6VXNlcjcyMTc1OTg=","avatar_url":"https://avatars1.githubusercontent.com/u/7217598?v=4","gravatar_id":"","url":"https://api.github.com/users/jeromefroe","html_url":"https://github.com/jeromefroe","followers_url":"https://api.github.com/users/jeromefroe/followers","following_url":"https://api.github.com/users/jeromefroe/following{/other_user}","gists_url":"https://api.github.com/users/jeromefroe/gists{/gist_id}","starred_url":"https://api.github.com/users/jeromefroe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeromefroe/subscriptions","organizations_url":"https://api.github.com/users/jeromefroe/orgs","repos_url":"https://api.github.com/users/jeromefroe/repos","events_url":"https://api.github.com/users/jeromefroe/events{/privacy}","received_events_url":"https://api.github.com/users/jeromefroe/received_events","type":"User","site_admin":false},"body":"This PR adds the initial implementation of the tally client for C++. The client is divided into two major libraries, `tally` and `m3`, each of which is in a top-level directory with the same name. The `tally` library defines the scope, reporter, and metrics (counters, gauges, timers, and histograms) interfaces. It provides a default implementation of a scope and the metrics. The `m3` library provides an implementation of the reporter interface for emitting metrics using the M3 thrift format.\r\n\r\n~~I still need to get CI setup fully but the code should be ready for review.~~ CI should be all set now.\r\n\r\nUnresolved questions:\r\n- [X] Conventions around exceptions. - Exceptions are permitted for exceptional cases, just not control flow.\r\n- [ ] Conventions for generated code.\r\n- [ ] Logging.","created_at":"2018-07-10T15:23:55Z","updated_at":"2018-07-12T19:24:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"35b712983f5327216659b0bbe5f5417779901887","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/m3db/tally-cpp/pulls/1/commits","review_comments_url":"https://api.github.com/repos/m3db/tally-cpp/pulls/1/comments","review_comment_url":"https://api.github.com/repos/m3db/tally-cpp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/m3db/tally-cpp/issues/1/comments","statuses_url":"https://api.github.com/repos/m3db/tally-cpp/statuses/fc40db747b2aac5543307d337969121ade209b6f","head":{"label":"m3db:jeromefroe/initial-implementation-of-tally","ref":"jeromefroe/initial-implementation-of-tally","sha":"fc40db747b2aac5543307d337969121ade209b6f","user":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"repo":{"id":136653889,"node_id":"MDEwOlJlcG9zaXRvcnkxMzY2NTM4ODk=","name":"tally-cpp","full_name":"m3db/tally-cpp","owner":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/m3db/tally-cpp","description":"C++ Tally Client","fork":false,"url":"https://api.github.com/repos/m3db/tally-cpp","forks_url":"https://api.github.com/repos/m3db/tally-cpp/forks","keys_url":"https://api.github.com/repos/m3db/tally-cpp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m3db/tally-cpp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m3db/tally-cpp/teams","hooks_url":"https://api.github.com/repos/m3db/tally-cpp/hooks","issue_events_url":"https://api.github.com/repos/m3db/tally-cpp/issues/events{/number}","events_url":"https://api.github.com/repos/m3db/tally-cpp/events","assignees_url":"https://api.github.com/repos/m3db/tally-cpp/assignees{/user}","branches_url":"https://api.github.com/repos/m3db/tally-cpp/branches{/branch}","tags_url":"https://api.github.com/repos/m3db/tally-cpp/tags","blobs_url":"https://api.github.com/repos/m3db/tally-cpp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m3db/tally-cpp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m3db/tally-cpp/git/refs{/sha}","trees_url":"https://api.github.com/repos/m3db/tally-cpp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m3db/tally-cpp/statuses/{sha}","languages_url":"https://api.github.com/repos/m3db/tally-cpp/languages","stargazers_url":"https://api.github.com/repos/m3db/tally-cpp/stargazers","contributors_url":"https://api.github.com/repos/m3db/tally-cpp/contributors","subscribers_url":"https://api.github.com/repos/m3db/tally-cpp/subscribers","subscription_url":"https://api.github.com/repos/m3db/tally-cpp/subscription","commits_url":"https://api.github.com/repos/m3db/tally-cpp/commits{/sha}","git_commits_url":"https://api.github.com/repos/m3db/tally-cpp/git/commits{/sha}","comments_url":"https://api.github.com/repos/m3db/tally-cpp/comments{/number}","issue_comment_url":"https://api.github.com/repos/m3db/tally-cpp/issues/comments{/number}","contents_url":"https://api.github.com/repos/m3db/tally-cpp/contents/{+path}","compare_url":"https://api.github.com/repos/m3db/tally-cpp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m3db/tally-cpp/merges","archive_url":"https://api.github.com/repos/m3db/tally-cpp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m3db/tally-cpp/downloads","issues_url":"https://api.github.com/repos/m3db/tally-cpp/issues{/number}","pulls_url":"https://api.github.com/repos/m3db/tally-cpp/pulls{/number}","milestones_url":"https://api.github.com/repos/m3db/tally-cpp/milestones{/number}","notifications_url":"https://api.github.com/repos/m3db/tally-cpp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m3db/tally-cpp/labels{/name}","releases_url":"https://api.github.com/repos/m3db/tally-cpp/releases{/id}","deployments_url":"https://api.github.com/repos/m3db/tally-cpp/deployments","created_at":"2018-06-08T18:35:24Z","updated_at":"2018-07-10T18:25:52Z","pushed_at":"2018-07-12T02:18:42Z","git_url":"git://github.com/m3db/tally-cpp.git","ssh_url":"git@github.com:m3db/tally-cpp.git","clone_url":"https://github.com/m3db/tally-cpp.git","svn_url":"https://github.com/m3db/tally-cpp","homepage":null,"size":110,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"m3db:master","ref":"master","sha":"12ee07e68c3cbd0d1d1126bee0a8dad64182a06e","user":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"repo":{"id":136653889,"node_id":"MDEwOlJlcG9zaXRvcnkxMzY2NTM4ODk=","name":"tally-cpp","full_name":"m3db/tally-cpp","owner":{"login":"m3db","id":19937171,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTM3MTcx","avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/m3db/tally-cpp","description":"C++ Tally Client","fork":false,"url":"https://api.github.com/repos/m3db/tally-cpp","forks_url":"https://api.github.com/repos/m3db/tally-cpp/forks","keys_url":"https://api.github.com/repos/m3db/tally-cpp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m3db/tally-cpp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m3db/tally-cpp/teams","hooks_url":"https://api.github.com/repos/m3db/tally-cpp/hooks","issue_events_url":"https://api.github.com/repos/m3db/tally-cpp/issues/events{/number}","events_url":"https://api.github.com/repos/m3db/tally-cpp/events","assignees_url":"https://api.github.com/repos/m3db/tally-cpp/assignees{/user}","branches_url":"https://api.github.com/repos/m3db/tally-cpp/branches{/branch}","tags_url":"https://api.github.com/repos/m3db/tally-cpp/tags","blobs_url":"https://api.github.com/repos/m3db/tally-cpp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m3db/tally-cpp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m3db/tally-cpp/git/refs{/sha}","trees_url":"https://api.github.com/repos/m3db/tally-cpp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m3db/tally-cpp/statuses/{sha}","languages_url":"https://api.github.com/repos/m3db/tally-cpp/languages","stargazers_url":"https://api.github.com/repos/m3db/tally-cpp/stargazers","contributors_url":"https://api.github.com/repos/m3db/tally-cpp/contributors","subscribers_url":"https://api.github.com/repos/m3db/tally-cpp/subscribers","subscription_url":"https://api.github.com/repos/m3db/tally-cpp/subscription","commits_url":"https://api.github.com/repos/m3db/tally-cpp/commits{/sha}","git_commits_url":"https://api.github.com/repos/m3db/tally-cpp/git/commits{/sha}","comments_url":"https://api.github.com/repos/m3db/tally-cpp/comments{/number}","issue_comment_url":"https://api.github.com/repos/m3db/tally-cpp/issues/comments{/number}","contents_url":"https://api.github.com/repos/m3db/tally-cpp/contents/{+path}","compare_url":"https://api.github.com/repos/m3db/tally-cpp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m3db/tally-cpp/merges","archive_url":"https://api.github.com/repos/m3db/tally-cpp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m3db/tally-cpp/downloads","issues_url":"https://api.github.com/repos/m3db/tally-cpp/issues{/number}","pulls_url":"https://api.github.com/repos/m3db/tally-cpp/pulls{/number}","milestones_url":"https://api.github.com/repos/m3db/tally-cpp/milestones{/number}","notifications_url":"https://api.github.com/repos/m3db/tally-cpp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m3db/tally-cpp/labels{/name}","releases_url":"https://api.github.com/repos/m3db/tally-cpp/releases{/id}","deployments_url":"https://api.github.com/repos/m3db/tally-cpp/deployments","created_at":"2018-06-08T18:35:24Z","updated_at":"2018-07-10T18:25:52Z","pushed_at":"2018-07-12T02:18:42Z","git_url":"git://github.com/m3db/tally-cpp.git","ssh_url":"git@github.com:m3db/tally-cpp.git","clone_url":"https://github.com/m3db/tally-cpp.git","svn_url":"https://github.com/m3db/tally-cpp","homepage":null,"size":110,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/m3db/tally-cpp/pulls/1"},"html":{"href":"https://github.com/m3db/tally-cpp/pull/1"},"issue":{"href":"https://api.github.com/repos/m3db/tally-cpp/issues/1"},"comments":{"href":"https://api.github.com/repos/m3db/tally-cpp/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/m3db/tally-cpp/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/m3db/tally-cpp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/m3db/tally-cpp/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/m3db/tally-cpp/statuses/fc40db747b2aac5543307d337969121ade209b6f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jeromefroe"}}