{"action":"created","comment":{"url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/comments/36808845","id":36808845,"diff_hunk":"@@ -6,31 +6,113 @@ Client for OT flavoured service discovery. (Note we are in the process of open-s\n installation:\n \n ```\n-npm install ot-discovery\n+npm install ot-discovery --save\n ```\n \n usage:\n \n-for a full example, see demo.js\n \n-```\n+``` javascript\n+//constructor \n+/* DiscoveryClient(host, announcementHosts, homeRegionName, serviceName,\n+ *   options) \n+ * @param = {String} host The hostname to the discovery server.\n+ * @param {Array} [annoucementHosts] An array of announcement host names\n+ *   multiple for announcing in multiple disco regions.\n+ *   If not provided will use host.\n+ *   Please include hostname in the announcement hosts.\n+ *\n+ * @param {string} [homeRegionName] The name of hosted region your sevice is in\n+ * @param {String} [serviceName] The name of the service you will announce as.\n+ * @param {Object} [options] Options argument that takes the following:\n+ *      {\n+ *        logger: { log: function(level, message){}},\n+ *        apiv2Strict: true/[false]\n+ *      }\n+ * @returns {Object} Returns a discovery client object.\n+ */\n+\n var discovery = require(\"ot-discovery\");\n+var disco = new discovery('discovery-server.mydomain.com',\n+  ['discovery-server.mydomain.com', 'discovery-server.otherdomain.com'],\n+  'homeDiscoRegion', 'myServiceName', { /* options */});\n+\n+//alternatively the original v1 constructor will continue to work \n+// --but will not utilize apiv2 features, mostly multi region announce\n+// This may be eventually deprecated.\n+var disco = new discovery(\"discovery-server.mydomain.com\");\n \n-var disco = new discovery(\"discovery-server.mydomain.com\", { /* options */});\n ```\n \n options:\n \n-```\n+``` javascript\n {\n   logger: { // a logger object which implements the following signature\n-    log: function(severity, log){} // severity will be one of info, debug, error\n-  }\n+    log: function(severity, log){} // severity will be one of info, \n+    //debug, error\n+  },\n+  apiv2Strict: false //set to true to throw on not apiv2 params.\n }\n ```\n \n Using with ot-logger\n \n+``` javascript\n+new discovery('discovery-server.mydomain.com', \n+  ['discovery-server.mydomain.com', 'discovery-server.otherdomain.com'],\n+  'homeDiscoRegion', 'myServiceName', { logger: require(\"ot-logger\") });\n+```\n+\n+General API usage\n+\n+``` javascript \n+var discovery = require(\"./discovery\");\n+var disco = new discovery('discovery-server.mydomain.com', \n+  ['discovery-server.mydomain.com', 'discovery-server.otherdomain.com'],\n+  'homeDiscoRegion', 'myServiceName', { /* options */});\n+var that = this;\n+\n+disco.connect(function(err, host, servers){\n+  //Please note that your http server must be up and responding to requests\n+  //before announcing to a discovery server or you will be rejected\n+  disco.announce({\n+    \"serviceType\":\"myServiceType\",\n+    \"serviceUri\":\"http://1.1.1.1:3\"\n+  }, function(err, announcedItemLeases){\n+    //announcedItemLease is an array that MUST not be modified.\n+    console.log(\"We announced our service!\", announcedItems);\n+    //You should store these items (and do NOT modify them) somewhere\n+    // if you plan to unannouce your announcements.\n+    that._announcedItemLeases = announcedItemLeases\n+  }); \n+});\n+\n ```\n-new discovery(\"discovery-server.mydomain.com\", { logger: require(\"ot-logger\") });\n+\n+API Documentation\n+\n+``` javascript\n+  DiscoveryClient.prototype.announce = function(announcement, callback) {}\n+/* \n+ * @param = {Object} announcement - announcement object:\n+ *   {\n+ *      serviceType:'myServiceTypeName',\n+ *      serviceUri:'http://myuri.com'\n+ *   }\n+ * @param {function(err, announcedItemLeases )} callback Node style callback\n+ *   Please note that annoucedItemLeases is required to hold onto (UNMODIFIED)\n+ *     if you plan to use unannounce.\n+ *\n+ * @returns {Promise} Returns a promise object\n+ */\n+\n+  DiscoveryClient.prototype.unannounce = function(announcements, callback) {}\n+/*\n+ * @param = {Array} announcements - announcement array directly from \n+ *   DiscoveryClient.announce callback - MUST NOT BE MODIFIED- INCLUDING ORDER!","path":"README.md","position":116,"original_position":116,"commit_id":"c157fcf3b77a0811a7b49b80a303763de18ad537","original_commit_id":"c157fcf3b77a0811a7b49b80a303763de18ad537","user":{"login":"lastquestion","id":1095956,"avatar_url":"https://avatars.githubusercontent.com/u/1095956?v=3","gravatar_id":"","url":"https://api.github.com/users/lastquestion","html_url":"https://github.com/lastquestion","followers_url":"https://api.github.com/users/lastquestion/followers","following_url":"https://api.github.com/users/lastquestion/following{/other_user}","gists_url":"https://api.github.com/users/lastquestion/gists{/gist_id}","starred_url":"https://api.github.com/users/lastquestion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lastquestion/subscriptions","organizations_url":"https://api.github.com/users/lastquestion/orgs","repos_url":"https://api.github.com/users/lastquestion/repos","events_url":"https://api.github.com/users/lastquestion/events{/privacy}","received_events_url":"https://api.github.com/users/lastquestion/received_events","type":"User","site_admin":false},"body":"Call it `lease`. Clearer: `lease: an opaque object returned from `announce`. Do not modify this object`","created_at":"2015-08-11T22:45:50Z","updated_at":"2015-08-11T22:45:50Z","html_url":"https://github.com/opentable/ot-discovery-nodejs/pull/42#discussion_r36808845","pull_request_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/42","_links":{"self":{"href":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/comments/36808845"},"html":{"href":"https://github.com/opentable/ot-discovery-nodejs/pull/42#discussion_r36808845"},"pull_request":{"href":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/42","id":41934776,"html_url":"https://github.com/opentable/ot-discovery-nodejs/pull/42","diff_url":"https://github.com/opentable/ot-discovery-nodejs/pull/42.diff","patch_url":"https://github.com/opentable/ot-discovery-nodejs/pull/42.patch","issue_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/issues/42","number":42,"state":"open","locked":false,"title":"updated readme","user":{"login":"virtue3","id":1501801,"avatar_url":"https://avatars.githubusercontent.com/u/1501801?v=3","gravatar_id":"","url":"https://api.github.com/users/virtue3","html_url":"https://github.com/virtue3","followers_url":"https://api.github.com/users/virtue3/followers","following_url":"https://api.github.com/users/virtue3/following{/other_user}","gists_url":"https://api.github.com/users/virtue3/gists{/gist_id}","starred_url":"https://api.github.com/users/virtue3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virtue3/subscriptions","organizations_url":"https://api.github.com/users/virtue3/orgs","repos_url":"https://api.github.com/users/virtue3/repos","events_url":"https://api.github.com/users/virtue3/events{/privacy}","received_events_url":"https://api.github.com/users/virtue3/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-07T21:24:43Z","updated_at":"2015-08-11T22:45:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a3070a80bc9633d96491bb74914ae5f94f8c5f4b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/42/commits","review_comments_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/42/comments","review_comment_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/issues/42/comments","statuses_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/statuses/c157fcf3b77a0811a7b49b80a303763de18ad537","head":{"label":"opentable:update_the_readme","ref":"update_the_readme","sha":"c157fcf3b77a0811a7b49b80a303763de18ad537","user":{"login":"opentable","id":2653541,"avatar_url":"https://avatars.githubusercontent.com/u/2653541?v=3","gravatar_id":"","url":"https://api.github.com/users/opentable","html_url":"https://github.com/opentable","followers_url":"https://api.github.com/users/opentable/followers","following_url":"https://api.github.com/users/opentable/following{/other_user}","gists_url":"https://api.github.com/users/opentable/gists{/gist_id}","starred_url":"https://api.github.com/users/opentable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opentable/subscriptions","organizations_url":"https://api.github.com/users/opentable/orgs","repos_url":"https://api.github.com/users/opentable/repos","events_url":"https://api.github.com/users/opentable/events{/privacy}","received_events_url":"https://api.github.com/users/opentable/received_events","type":"Organization","site_admin":false},"repo":{"id":19999368,"name":"ot-discovery-nodejs","full_name":"opentable/ot-discovery-nodejs","owner":{"login":"opentable","id":2653541,"avatar_url":"https://avatars.githubusercontent.com/u/2653541?v=3","gravatar_id":"","url":"https://api.github.com/users/opentable","html_url":"https://github.com/opentable","followers_url":"https://api.github.com/users/opentable/followers","following_url":"https://api.github.com/users/opentable/following{/other_user}","gists_url":"https://api.github.com/users/opentable/gists{/gist_id}","starred_url":"https://api.github.com/users/opentable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opentable/subscriptions","organizations_url":"https://api.github.com/users/opentable/orgs","repos_url":"https://api.github.com/users/opentable/repos","events_url":"https://api.github.com/users/opentable/events{/privacy}","received_events_url":"https://api.github.com/users/opentable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opentable/ot-discovery-nodejs","description":"Node.JS Discovery Client","fork":false,"url":"https://api.github.com/repos/opentable/ot-discovery-nodejs","forks_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/forks","keys_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/teams","hooks_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/hooks","issue_events_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/issues/events{/number}","events_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/events","assignees_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/assignees{/user}","branches_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/branches{/branch}","tags_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/tags","blobs_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/git/refs{/sha}","trees_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/statuses/{sha}","languages_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/languages","stargazers_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/stargazers","contributors_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/contributors","subscribers_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/subscribers","subscription_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/subscription","commits_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/commits{/sha}","git_commits_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/git/commits{/sha}","comments_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/comments{/number}","issue_comment_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/issues/comments{/number}","contents_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/contents/{+path}","compare_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/merges","archive_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/downloads","issues_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/issues{/number}","pulls_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls{/number}","milestones_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/milestones{/number}","notifications_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/labels{/name}","releases_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/releases{/id}","created_at":"2014-05-20T22:09:05Z","updated_at":"2015-04-29T18:05:23Z","pushed_at":"2015-08-11T22:38:21Z","git_url":"git://github.com/opentable/ot-discovery-nodejs.git","ssh_url":"git@github.com:opentable/ot-discovery-nodejs.git","clone_url":"https://github.com/opentable/ot-discovery-nodejs.git","svn_url":"https://github.com/opentable/ot-discovery-nodejs","homepage":null,"size":770,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":6,"forks":14,"open_issues":6,"watchers":1,"default_branch":"master"}},"base":{"label":"opentable:v1-pre","ref":"v1-pre","sha":"184c89e2bfd65d772283222b46180007b0d0918d","user":{"login":"opentable","id":2653541,"avatar_url":"https://avatars.githubusercontent.com/u/2653541?v=3","gravatar_id":"","url":"https://api.github.com/users/opentable","html_url":"https://github.com/opentable","followers_url":"https://api.github.com/users/opentable/followers","following_url":"https://api.github.com/users/opentable/following{/other_user}","gists_url":"https://api.github.com/users/opentable/gists{/gist_id}","starred_url":"https://api.github.com/users/opentable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opentable/subscriptions","organizations_url":"https://api.github.com/users/opentable/orgs","repos_url":"https://api.github.com/users/opentable/repos","events_url":"https://api.github.com/users/opentable/events{/privacy}","received_events_url":"https://api.github.com/users/opentable/received_events","type":"Organization","site_admin":false},"repo":{"id":19999368,"name":"ot-discovery-nodejs","full_name":"opentable/ot-discovery-nodejs","owner":{"login":"opentable","id":2653541,"avatar_url":"https://avatars.githubusercontent.com/u/2653541?v=3","gravatar_id":"","url":"https://api.github.com/users/opentable","html_url":"https://github.com/opentable","followers_url":"https://api.github.com/users/opentable/followers","following_url":"https://api.github.com/users/opentable/following{/other_user}","gists_url":"https://api.github.com/users/opentable/gists{/gist_id}","starred_url":"https://api.github.com/users/opentable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opentable/subscriptions","organizations_url":"https://api.github.com/users/opentable/orgs","repos_url":"https://api.github.com/users/opentable/repos","events_url":"https://api.github.com/users/opentable/events{/privacy}","received_events_url":"https://api.github.com/users/opentable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opentable/ot-discovery-nodejs","description":"Node.JS Discovery Client","fork":false,"url":"https://api.github.com/repos/opentable/ot-discovery-nodejs","forks_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/forks","keys_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/teams","hooks_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/hooks","issue_events_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/issues/events{/number}","events_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/events","assignees_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/assignees{/user}","branches_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/branches{/branch}","tags_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/tags","blobs_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/git/refs{/sha}","trees_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/statuses/{sha}","languages_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/languages","stargazers_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/stargazers","contributors_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/contributors","subscribers_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/subscribers","subscription_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/subscription","commits_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/commits{/sha}","git_commits_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/git/commits{/sha}","comments_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/comments{/number}","issue_comment_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/issues/comments{/number}","contents_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/contents/{+path}","compare_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/merges","archive_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/downloads","issues_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/issues{/number}","pulls_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls{/number}","milestones_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/milestones{/number}","notifications_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/labels{/name}","releases_url":"https://api.github.com/repos/opentable/ot-discovery-nodejs/releases{/id}","created_at":"2014-05-20T22:09:05Z","updated_at":"2015-04-29T18:05:23Z","pushed_at":"2015-08-11T22:38:21Z","git_url":"git://github.com/opentable/ot-discovery-nodejs.git","ssh_url":"git@github.com:opentable/ot-discovery-nodejs.git","clone_url":"https://github.com/opentable/ot-discovery-nodejs.git","svn_url":"https://github.com/opentable/ot-discovery-nodejs","homepage":null,"size":770,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":6,"forks":14,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/42"},"html":{"href":"https://github.com/opentable/ot-discovery-nodejs/pull/42"},"issue":{"href":"https://api.github.com/repos/opentable/ot-discovery-nodejs/issues/42"},"comments":{"href":"https://api.github.com/repos/opentable/ot-discovery-nodejs/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opentable/ot-discovery-nodejs/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/opentable/ot-discovery-nodejs/statuses/c157fcf3b77a0811a7b49b80a303763de18ad537"}}}}