{"action":"created","comment":{"url":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/comments/55867843","id":55867843,"diff_hunk":"@@ -0,0 +1,200 @@\n+#include \"Pull.h\"\n+#include <stdexcept>\n+#include <g3log/g3log.hpp>\n+/**\n+ * Construct a blocking nanomsg pull (no timeout)\n+ */\n+Pull::Pull(const std::string& location, const bool shouldConnect) {\n+   mProtocolHandler = std::move(std::unique_ptr<NanoProtocol>(\n+                                   new NanoProtocol(location)));\n+   mSocket = nn_socket(AF_SP, NN_PULL);\n+   if (mSocket < 0) {\n+      throw std::runtime_error(\"could not open transport socket\" +\n+                               mProtocolHandler->GetLocation() +\n+                               \" because of error: \" +\n+                               std::string(nn_strerror(errno)));\n+   }\n+   int connectResponse = {0};\n+   std::string connectionType(\"\");\n+   if (shouldConnect){\n+      connectResponse = nn_connect(mSocket,\n+                                   mProtocolHandler->GetLocation().c_str());\n+      connectionType = \"nn_connect\";\n+   } else{\n+      connectResponse = nn_bind(mSocket,\n+                                mProtocolHandler->GetLocation().c_str());\n+      connectionType = \"nn_bind\";\n+   }\n+   if (connectResponse < 0) {\n+      throw std::runtime_error(\"could not connect to endpoint: \" +\n+                               mProtocolHandler->GetLocation() +\n+                               \" because of error: \" +\n+                               std::string(nn_strerror(errno)));\n+   }\n+   LOG(INFO) << connectionType\n+              << \" socket at: \" << mProtocolHandler->GetLocation();\n+}\n+/**\n+ * Construct a non-blocking nanomsg pull (timeout)\n+ */\n+Pull::Pull(const std::string& location,\n+                 const int timeoutInMs,\n+                 const bool shouldConnect) {\n+   mProtocolHandler = std::move(std::unique_ptr<NanoProtocol>(\n+                                   new NanoProtocol(location)));\n+   mSocket = nn_socket(AF_SP, NN_PULL);\n+   if (mSocket < 0) {\n+      throw std::runtime_error(\"could not open transport socket\" +\n+                               mProtocolHandler->GetLocation() +\n+                               \" because of error: \" +\n+                               std::string(nn_strerror(errno)));\n+   }\n+   nn_setsockopt(mSocket,\n+                 NN_SOL_SOCKET,\n+                 NN_RCVTIMEO,\n+                 &timeoutInMs,\n+                 sizeof (timeoutInMs));\n+   int connectResponse = {0};\n+   std::string connectionType(\"\");\n+   if (shouldConnect){\n+      connectResponse = nn_connect(mSocket,\n+                                   mProtocolHandler->GetLocation().c_str());\n+      connectionType = \"nn_connect\";\n+   } else{\n+      connectResponse = nn_bind(mSocket,\n+                                mProtocolHandler->GetLocation().c_str());\n+      connectionType = \"nn_bind\";\n+   }\n+   if (connectResponse < 0) {\n+      throw std::runtime_error(\"could not connect to endpoint: \" +\n+                               mProtocolHandler->GetLocation() +\n+                               \" because of error: \" +\n+                               std::string(nn_strerror(errno)));\n+   }\n+   LOG(INFO) << connectionType\n+              << \" socket at: \" << mProtocolHandler->GetLocation()\n+              << \" with timeout: \" << timeoutInMs;\n+}\n+/**\n+ * Construct a non-blocking nanomsg pull (timeout)\n+ */\n+Pull::Pull(const std::string& location,\n+           const int timeoutInMs,\n+           const int bufferSize,\n+           const bool shouldConnect) {\n+   mProtocolHandler = std::move(std::unique_ptr<NanoProtocol>(\n+                                   new NanoProtocol(location)));\n+   mSocket = nn_socket(AF_SP, NN_PULL);\n+   if (mSocket < 0) {\n+      throw std::runtime_error(\"could not open transport socket\" +\n+                               mProtocolHandler->GetLocation() +\n+                               \" because of error: \" +\n+                               std::string(nn_strerror(errno)));\n+   }\n+   if (timeoutInMs > 0) {\n+      nn_setsockopt(mSocket,\n+                    NN_SOL_SOCKET,\n+                    NN_RCVTIMEO,\n+                    &timeoutInMs,\n+                    sizeof(timeoutInMs));\n+   } else {\n+      LOG(INFO) << \" zero or negative timeout requested, blocking socket\";\n+   }\n+   nn_setsockopt(mSocket,\n+                 NN_SOL_SOCKET,\n+                 NN_RCVBUF,\n+                 &bufferSize,\n+                 sizeof(bufferSize));\n+   int connectResponse = {0};\n+   std::string connectionType(\"\");\n+   if (shouldConnect){\n+      connectResponse = nn_connect(mSocket,\n+                                   mProtocolHandler->GetLocation().c_str());\n+      connectionType = \"nn_connect\";\n+   } else{\n+      connectResponse = nn_bind(mSocket,\n+                                mProtocolHandler->GetLocation().c_str());\n+      connectionType = \"nn_bind\";\n+   }\n+   if (connectResponse < 0) {\n+      throw std::runtime_error(\"could not connect to endpoint: \" +\n+                               mProtocolHandler->GetLocation() +\n+                               \" because of error: \" +\n+                               std::string(nn_strerror(errno)));\n+   }\n+   LOG(INFO) << connectionType\n+              << \" socket at: \" << mProtocolHandler->GetLocation()\n+              << \" with timeout: \" << timeoutInMs;\n+}\n+/**\n+ * Return the socket location\n+ */\n+std::string Pull::GetBinding() const {\n+   return mProtocolHandler->GetLocation();\n+}\n+/**\n+ * Receive a msg from the nanomsg queue, check for errors\n+ */\n+int Pull::ReceiveMsg(void *& buf, bool dontWait) {\n+   auto num_bytes_received = nn_recv(mSocket,\n+                                     &buf,\n+                                     NN_MSG,\n+                                     dontWait? NN_DONTWAIT : 0);\n+   if (num_bytes_received < 0) {\n+      auto error = nn_errno ();\n+      if (error == ETIMEDOUT) {\n+         throw std::runtime_error(\"timed out receiving message\");","path":"src/Pull.cpp","position":146,"original_position":146,"commit_id":"6aef32ff2c5e27755093d2ac9c65c6b7703395d3","original_commit_id":"6aef32ff2c5e27755093d2ac9c65c6b7703395d3","user":{"login":"KjellKod","id":331742,"avatar_url":"https://avatars.githubusercontent.com/u/331742?v=3","gravatar_id":"","url":"https://api.github.com/users/KjellKod","html_url":"https://github.com/KjellKod","followers_url":"https://api.github.com/users/KjellKod/followers","following_url":"https://api.github.com/users/KjellKod/following{/other_user}","gists_url":"https://api.github.com/users/KjellKod/gists{/gist_id}","starred_url":"https://api.github.com/users/KjellKod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KjellKod/subscriptions","organizations_url":"https://api.github.com/users/KjellKod/orgs","repos_url":"https://api.github.com/users/KjellKod/repos","events_url":"https://api.github.com/users/KjellKod/events{/privacy}","received_events_url":"https://api.github.com/users/KjellKod/received_events","type":"User","site_admin":false},"body":"I'm almost positive that we do not want exception to be thrown here.  Is it really an ```exceptional case``` that we do not receive a message? Please consider startup / shutdown scenarios. ","created_at":"2016-03-11T18:28:39Z","updated_at":"2016-03-11T18:28:39Z","html_url":"https://github.com/LogRhythm/QueueNado/pull/40#discussion_r55867843","pull_request_url":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/40","_links":{"self":{"href":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/comments/55867843"},"html":{"href":"https://github.com/LogRhythm/QueueNado/pull/40#discussion_r55867843"},"pull_request":{"href":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/40"}}},"pull_request":{"url":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/40","id":61312167,"html_url":"https://github.com/LogRhythm/QueueNado/pull/40","diff_url":"https://github.com/LogRhythm/QueueNado/pull/40.diff","patch_url":"https://github.com/LogRhythm/QueueNado/pull/40.patch","issue_url":"https://api.github.com/repos/LogRhythm/QueueNado/issues/40","number":40,"state":"open","locked":false,"title":"Added nanomsg classes - DO NOT MERGE","user":{"login":"yannick-polius","id":14659345,"avatar_url":"https://avatars.githubusercontent.com/u/14659345?v=3","gravatar_id":"","url":"https://api.github.com/users/yannick-polius","html_url":"https://github.com/yannick-polius","followers_url":"https://api.github.com/users/yannick-polius/followers","following_url":"https://api.github.com/users/yannick-polius/following{/other_user}","gists_url":"https://api.github.com/users/yannick-polius/gists{/gist_id}","starred_url":"https://api.github.com/users/yannick-polius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yannick-polius/subscriptions","organizations_url":"https://api.github.com/users/yannick-polius/orgs","repos_url":"https://api.github.com/users/yannick-polius/repos","events_url":"https://api.github.com/users/yannick-polius/events{/privacy}","received_events_url":"https://api.github.com/users/yannick-polius/received_events","type":"User","site_admin":false},"body":"new PR to just add a new queuenado pattern using nanomsg.\r\n\r\nplease review for design to ensure there is nothing out of the ordinary. you will not be able to build this unless you have nanomsg installed.\r\n\r\nplease check for typos/code style errors, but you only need to point them out once per file, as I have an editor that I can use to set the style for the entire file.\r\n\r\nTODO:\r\n\r\nintegrate with research where we want to test perofrmance\r\n","created_at":"2016-03-01T21:34:29Z","updated_at":"2016-03-11T18:28:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"332f7f61f83ea6f2b96f36f484c6dab4f4afbbfc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/40/commits","review_comments_url":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/40/comments","review_comment_url":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LogRhythm/QueueNado/issues/40/comments","statuses_url":"https://api.github.com/repos/LogRhythm/QueueNado/statuses/6aef32ff2c5e27755093d2ac9c65c6b7703395d3","head":{"label":"yannick-polius:update/add_nano_push_pull","ref":"update/add_nano_push_pull","sha":"6aef32ff2c5e27755093d2ac9c65c6b7703395d3","user":{"login":"yannick-polius","id":14659345,"avatar_url":"https://avatars.githubusercontent.com/u/14659345?v=3","gravatar_id":"","url":"https://api.github.com/users/yannick-polius","html_url":"https://github.com/yannick-polius","followers_url":"https://api.github.com/users/yannick-polius/followers","following_url":"https://api.github.com/users/yannick-polius/following{/other_user}","gists_url":"https://api.github.com/users/yannick-polius/gists{/gist_id}","starred_url":"https://api.github.com/users/yannick-polius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yannick-polius/subscriptions","organizations_url":"https://api.github.com/users/yannick-polius/orgs","repos_url":"https://api.github.com/users/yannick-polius/repos","events_url":"https://api.github.com/users/yannick-polius/events{/privacy}","received_events_url":"https://api.github.com/users/yannick-polius/received_events","type":"User","site_admin":false},"repo":{"id":42898619,"name":"QueueNado","full_name":"yannick-polius/QueueNado","owner":{"login":"yannick-polius","id":14659345,"avatar_url":"https://avatars.githubusercontent.com/u/14659345?v=3","gravatar_id":"","url":"https://api.github.com/users/yannick-polius","html_url":"https://github.com/yannick-polius","followers_url":"https://api.github.com/users/yannick-polius/followers","following_url":"https://api.github.com/users/yannick-polius/following{/other_user}","gists_url":"https://api.github.com/users/yannick-polius/gists{/gist_id}","starred_url":"https://api.github.com/users/yannick-polius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yannick-polius/subscriptions","organizations_url":"https://api.github.com/users/yannick-polius/orgs","repos_url":"https://api.github.com/users/yannick-polius/repos","events_url":"https://api.github.com/users/yannick-polius/events{/privacy}","received_events_url":"https://api.github.com/users/yannick-polius/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yannick-polius/QueueNado","description":"Implementation of fast queue patterns (Push/Pull, request/reply, pub/sub, dealer/router) for C++","fork":true,"url":"https://api.github.com/repos/yannick-polius/QueueNado","forks_url":"https://api.github.com/repos/yannick-polius/QueueNado/forks","keys_url":"https://api.github.com/repos/yannick-polius/QueueNado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yannick-polius/QueueNado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yannick-polius/QueueNado/teams","hooks_url":"https://api.github.com/repos/yannick-polius/QueueNado/hooks","issue_events_url":"https://api.github.com/repos/yannick-polius/QueueNado/issues/events{/number}","events_url":"https://api.github.com/repos/yannick-polius/QueueNado/events","assignees_url":"https://api.github.com/repos/yannick-polius/QueueNado/assignees{/user}","branches_url":"https://api.github.com/repos/yannick-polius/QueueNado/branches{/branch}","tags_url":"https://api.github.com/repos/yannick-polius/QueueNado/tags","blobs_url":"https://api.github.com/repos/yannick-polius/QueueNado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yannick-polius/QueueNado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yannick-polius/QueueNado/git/refs{/sha}","trees_url":"https://api.github.com/repos/yannick-polius/QueueNado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yannick-polius/QueueNado/statuses/{sha}","languages_url":"https://api.github.com/repos/yannick-polius/QueueNado/languages","stargazers_url":"https://api.github.com/repos/yannick-polius/QueueNado/stargazers","contributors_url":"https://api.github.com/repos/yannick-polius/QueueNado/contributors","subscribers_url":"https://api.github.com/repos/yannick-polius/QueueNado/subscribers","subscription_url":"https://api.github.com/repos/yannick-polius/QueueNado/subscription","commits_url":"https://api.github.com/repos/yannick-polius/QueueNado/commits{/sha}","git_commits_url":"https://api.github.com/repos/yannick-polius/QueueNado/git/commits{/sha}","comments_url":"https://api.github.com/repos/yannick-polius/QueueNado/comments{/number}","issue_comment_url":"https://api.github.com/repos/yannick-polius/QueueNado/issues/comments{/number}","contents_url":"https://api.github.com/repos/yannick-polius/QueueNado/contents/{+path}","compare_url":"https://api.github.com/repos/yannick-polius/QueueNado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yannick-polius/QueueNado/merges","archive_url":"https://api.github.com/repos/yannick-polius/QueueNado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yannick-polius/QueueNado/downloads","issues_url":"https://api.github.com/repos/yannick-polius/QueueNado/issues{/number}","pulls_url":"https://api.github.com/repos/yannick-polius/QueueNado/pulls{/number}","milestones_url":"https://api.github.com/repos/yannick-polius/QueueNado/milestones{/number}","notifications_url":"https://api.github.com/repos/yannick-polius/QueueNado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yannick-polius/QueueNado/labels{/name}","releases_url":"https://api.github.com/repos/yannick-polius/QueueNado/releases{/id}","deployments_url":"https://api.github.com/repos/yannick-polius/QueueNado/deployments","created_at":"2015-09-21T23:07:53Z","updated_at":"2016-02-09T22:15:42Z","pushed_at":"2016-03-08T05:55:50Z","git_url":"git://github.com/yannick-polius/QueueNado.git","ssh_url":"git@github.com:yannick-polius/QueueNado.git","clone_url":"https://github.com/yannick-polius/QueueNado.git","svn_url":"https://github.com/yannick-polius/QueueNado","homepage":null,"size":3274,"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":"LogRhythm:master","ref":"master","sha":"00b4d2d3467d998c9608dae23a55d55607278a83","user":{"login":"LogRhythm","id":4572303,"avatar_url":"https://avatars.githubusercontent.com/u/4572303?v=3","gravatar_id":"","url":"https://api.github.com/users/LogRhythm","html_url":"https://github.com/LogRhythm","followers_url":"https://api.github.com/users/LogRhythm/followers","following_url":"https://api.github.com/users/LogRhythm/following{/other_user}","gists_url":"https://api.github.com/users/LogRhythm/gists{/gist_id}","starred_url":"https://api.github.com/users/LogRhythm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LogRhythm/subscriptions","organizations_url":"https://api.github.com/users/LogRhythm/orgs","repos_url":"https://api.github.com/users/LogRhythm/repos","events_url":"https://api.github.com/users/LogRhythm/events{/privacy}","received_events_url":"https://api.github.com/users/LogRhythm/received_events","type":"Organization","site_admin":false},"repo":{"id":19793324,"name":"QueueNado","full_name":"LogRhythm/QueueNado","owner":{"login":"LogRhythm","id":4572303,"avatar_url":"https://avatars.githubusercontent.com/u/4572303?v=3","gravatar_id":"","url":"https://api.github.com/users/LogRhythm","html_url":"https://github.com/LogRhythm","followers_url":"https://api.github.com/users/LogRhythm/followers","following_url":"https://api.github.com/users/LogRhythm/following{/other_user}","gists_url":"https://api.github.com/users/LogRhythm/gists{/gist_id}","starred_url":"https://api.github.com/users/LogRhythm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LogRhythm/subscriptions","organizations_url":"https://api.github.com/users/LogRhythm/orgs","repos_url":"https://api.github.com/users/LogRhythm/repos","events_url":"https://api.github.com/users/LogRhythm/events{/privacy}","received_events_url":"https://api.github.com/users/LogRhythm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LogRhythm/QueueNado","description":"Implementation of fast queue patterns (Push/Pull, request/reply, pub/sub, dealer/router) for C++","fork":false,"url":"https://api.github.com/repos/LogRhythm/QueueNado","forks_url":"https://api.github.com/repos/LogRhythm/QueueNado/forks","keys_url":"https://api.github.com/repos/LogRhythm/QueueNado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LogRhythm/QueueNado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LogRhythm/QueueNado/teams","hooks_url":"https://api.github.com/repos/LogRhythm/QueueNado/hooks","issue_events_url":"https://api.github.com/repos/LogRhythm/QueueNado/issues/events{/number}","events_url":"https://api.github.com/repos/LogRhythm/QueueNado/events","assignees_url":"https://api.github.com/repos/LogRhythm/QueueNado/assignees{/user}","branches_url":"https://api.github.com/repos/LogRhythm/QueueNado/branches{/branch}","tags_url":"https://api.github.com/repos/LogRhythm/QueueNado/tags","blobs_url":"https://api.github.com/repos/LogRhythm/QueueNado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LogRhythm/QueueNado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LogRhythm/QueueNado/git/refs{/sha}","trees_url":"https://api.github.com/repos/LogRhythm/QueueNado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LogRhythm/QueueNado/statuses/{sha}","languages_url":"https://api.github.com/repos/LogRhythm/QueueNado/languages","stargazers_url":"https://api.github.com/repos/LogRhythm/QueueNado/stargazers","contributors_url":"https://api.github.com/repos/LogRhythm/QueueNado/contributors","subscribers_url":"https://api.github.com/repos/LogRhythm/QueueNado/subscribers","subscription_url":"https://api.github.com/repos/LogRhythm/QueueNado/subscription","commits_url":"https://api.github.com/repos/LogRhythm/QueueNado/commits{/sha}","git_commits_url":"https://api.github.com/repos/LogRhythm/QueueNado/git/commits{/sha}","comments_url":"https://api.github.com/repos/LogRhythm/QueueNado/comments{/number}","issue_comment_url":"https://api.github.com/repos/LogRhythm/QueueNado/issues/comments{/number}","contents_url":"https://api.github.com/repos/LogRhythm/QueueNado/contents/{+path}","compare_url":"https://api.github.com/repos/LogRhythm/QueueNado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LogRhythm/QueueNado/merges","archive_url":"https://api.github.com/repos/LogRhythm/QueueNado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LogRhythm/QueueNado/downloads","issues_url":"https://api.github.com/repos/LogRhythm/QueueNado/issues{/number}","pulls_url":"https://api.github.com/repos/LogRhythm/QueueNado/pulls{/number}","milestones_url":"https://api.github.com/repos/LogRhythm/QueueNado/milestones{/number}","notifications_url":"https://api.github.com/repos/LogRhythm/QueueNado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LogRhythm/QueueNado/labels{/name}","releases_url":"https://api.github.com/repos/LogRhythm/QueueNado/releases{/id}","deployments_url":"https://api.github.com/repos/LogRhythm/QueueNado/deployments","created_at":"2014-05-14T19:34:03Z","updated_at":"2016-02-09T22:15:41Z","pushed_at":"2016-03-08T05:55:50Z","git_url":"git://github.com/LogRhythm/QueueNado.git","ssh_url":"git@github.com:LogRhythm/QueueNado.git","clone_url":"https://github.com/LogRhythm/QueueNado.git","svn_url":"https://github.com/LogRhythm/QueueNado","homepage":null,"size":3205,"stargazers_count":6,"watchers_count":6,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":1,"forks":9,"open_issues":1,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/40"},"html":{"href":"https://github.com/LogRhythm/QueueNado/pull/40"},"issue":{"href":"https://api.github.com/repos/LogRhythm/QueueNado/issues/40"},"comments":{"href":"https://api.github.com/repos/LogRhythm/QueueNado/issues/40/comments"},"review_comments":{"href":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/40/comments"},"review_comment":{"href":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LogRhythm/QueueNado/pulls/40/commits"},"statuses":{"href":"https://api.github.com/repos/LogRhythm/QueueNado/statuses/6aef32ff2c5e27755093d2ac9c65c6b7703395d3"}}}}