{"action":"created","comment":{"url":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/comments/28583273","id":28583273,"diff_hunk":"@@ -0,0 +1,383 @@\n+/*******************************************************************************\n+The MIT License (MIT)\n+\n+Copyright (c) 2015 Dmitry \"Dima\" Korolev <dmitry.korolev@gmail.com>\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 all\n+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 THE\n+SOFTWARE.\n+*******************************************************************************/\n+\n+#ifndef SHERLOCK_KV_STORAGE_H\n+#define SHERLOCK_KV_STORAGE_H\n+\n+#include <atomic>\n+#include <future>\n+#include <string>\n+\n+#include \"sherlock.h\"\n+\n+#include \"../Bricks/mq/inmemory/mq.h\"\n+\n+namespace sherlock {\n+namespace kv_storage {\n+// Base structures for user entry types.\n+struct AllowNonThrowingGet {\n+  constexpr static bool allow_nonthrowing_get = true;\n+};\n+\n+enum NullEntryTypeHelper { NullEntry };\n+struct Nullable {\n+  const bool exists;\n+  Nullable() : exists(true) {}\n+  Nullable(NullEntryTypeHelper) : exists(false) {}\n+};\n+\n+struct Deletable {};  // User promises to serialize Nullable::exists;\n+\n+// Universal null entry creation.\n+template <typename T_ENTRY, bool IS_NULLABLE>\n+struct GetNullEntry {\n+  static T_ENTRY get() {\n+    static_assert(true, \"Should never happen.\");\n+    return T_ENTRY();\n+  }\n+};\n+\n+template <typename T_ENTRY>\n+struct GetNullEntry<T_ENTRY, true> {\n+  static T_ENTRY get() {\n+    T_ENTRY e(NullEntry);\n+    return e;\n+  }\n+};\n+\n+template <typename T_ENTRY, bool IS_NULLABLE>\n+T_ENTRY CreateNullEntry() { return GetNullEntry<T_ENTRY, IS_NULLABLE>::get(); }\n+\n+// Exceptions.\n+struct KeyNotFoundException : bricks::Exception {};\n+\n+template <typename T_ENTRY>\n+struct SpecificEntryTypeKeyNotFoundException : KeyNotFoundException {\n+  typedef typename std::remove_reference<decltype(std::declval<T_ENTRY>().key())>::type T_KEY;","path":"kv_storage.h","position":77,"original_position":77,"commit_id":"157ee5a7c64803a6877c8ba4e94927a4ab46ccdd","original_commit_id":"157ee5a7c64803a6877c8ba4e94927a4ab46ccdd","user":{"login":"dkorolev","id":2159447,"avatar_url":"https://avatars.githubusercontent.com/u/2159447?v=3","gravatar_id":"","url":"https://api.github.com/users/dkorolev","html_url":"https://github.com/dkorolev","followers_url":"https://api.github.com/users/dkorolev/followers","following_url":"https://api.github.com/users/dkorolev/following{/other_user}","gists_url":"https://api.github.com/users/dkorolev/gists{/gist_id}","starred_url":"https://api.github.com/users/dkorolev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkorolev/subscriptions","organizations_url":"https://api.github.com/users/dkorolev/orgs","repos_url":"https://api.github.com/users/dkorolev/repos","events_url":"https://api.github.com/users/dkorolev/events{/privacy}","received_events_url":"https://api.github.com/users/dkorolev/received_events","type":"User","site_admin":false},"body":"Do we need `std::remove_cv` here and in the other place we use `decltype(std::declvar<T_ENTRY>().key())`?","created_at":"2015-04-17T10:15:40Z","updated_at":"2015-04-17T10:15:40Z","html_url":"https://github.com/KnowSheet/Sherlock/pull/15#discussion_r28583273","pull_request_url":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/comments/28583273"},"html":{"href":"https://github.com/KnowSheet/Sherlock/pull/15#discussion_r28583273"},"pull_request":{"href":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/15","id":33502747,"html_url":"https://github.com/KnowSheet/Sherlock/pull/15","diff_url":"https://github.com/KnowSheet/Sherlock/pull/15.diff","patch_url":"https://github.com/KnowSheet/Sherlock/pull/15.patch","issue_url":"https://api.github.com/repos/KnowSheet/Sherlock/issues/15","number":15,"state":"open","locked":false,"title":"Fresh version of KV Storage. Get() and Add() with policies.","user":{"login":"mzhurovich","id":11226961,"avatar_url":"https://avatars.githubusercontent.com/u/11226961?v=3","gravatar_id":"","url":"https://api.github.com/users/mzhurovich","html_url":"https://github.com/mzhurovich","followers_url":"https://api.github.com/users/mzhurovich/followers","following_url":"https://api.github.com/users/mzhurovich/following{/other_user}","gists_url":"https://api.github.com/users/mzhurovich/gists{/gist_id}","starred_url":"https://api.github.com/users/mzhurovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzhurovich/subscriptions","organizations_url":"https://api.github.com/users/mzhurovich/orgs","repos_url":"https://api.github.com/users/mzhurovich/repos","events_url":"https://api.github.com/users/mzhurovich/events{/privacy}","received_events_url":"https://api.github.com/users/mzhurovich/received_events","type":"User","site_admin":false},"body":"@dkorolev PTAL.","created_at":"2015-04-16T23:30:36Z","updated_at":"2015-04-17T10:15:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa3379db04a67397394040cca333db512e5d8b50","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/15/commits","review_comments_url":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/15/comments","review_comment_url":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/comments{/number}","comments_url":"https://api.github.com/repos/KnowSheet/Sherlock/issues/15/comments","statuses_url":"https://api.github.com/repos/KnowSheet/Sherlock/statuses/157ee5a7c64803a6877c8ba4e94927a4ab46ccdd","head":{"label":"mzhurovich:kv-storage","ref":"kv-storage","sha":"157ee5a7c64803a6877c8ba4e94927a4ab46ccdd","user":{"login":"mzhurovich","id":11226961,"avatar_url":"https://avatars.githubusercontent.com/u/11226961?v=3","gravatar_id":"","url":"https://api.github.com/users/mzhurovich","html_url":"https://github.com/mzhurovich","followers_url":"https://api.github.com/users/mzhurovich/followers","following_url":"https://api.github.com/users/mzhurovich/following{/other_user}","gists_url":"https://api.github.com/users/mzhurovich/gists{/gist_id}","starred_url":"https://api.github.com/users/mzhurovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzhurovich/subscriptions","organizations_url":"https://api.github.com/users/mzhurovich/orgs","repos_url":"https://api.github.com/users/mzhurovich/repos","events_url":"https://api.github.com/users/mzhurovich/events{/privacy}","received_events_url":"https://api.github.com/users/mzhurovich/received_events","type":"User","site_admin":false},"repo":{"id":33790556,"name":"Sherlock","full_name":"mzhurovich/Sherlock","owner":{"login":"mzhurovich","id":11226961,"avatar_url":"https://avatars.githubusercontent.com/u/11226961?v=3","gravatar_id":"","url":"https://api.github.com/users/mzhurovich","html_url":"https://github.com/mzhurovich","followers_url":"https://api.github.com/users/mzhurovich/followers","following_url":"https://api.github.com/users/mzhurovich/following{/other_user}","gists_url":"https://api.github.com/users/mzhurovich/gists{/gist_id}","starred_url":"https://api.github.com/users/mzhurovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzhurovich/subscriptions","organizations_url":"https://api.github.com/users/mzhurovich/orgs","repos_url":"https://api.github.com/users/mzhurovich/repos","events_url":"https://api.github.com/users/mzhurovich/events{/privacy}","received_events_url":"https://api.github.com/users/mzhurovich/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mzhurovich/Sherlock","description":"Structured, append-only, immutable data persistence layer with publish-subscribe.","fork":true,"url":"https://api.github.com/repos/mzhurovich/Sherlock","forks_url":"https://api.github.com/repos/mzhurovich/Sherlock/forks","keys_url":"https://api.github.com/repos/mzhurovich/Sherlock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mzhurovich/Sherlock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mzhurovich/Sherlock/teams","hooks_url":"https://api.github.com/repos/mzhurovich/Sherlock/hooks","issue_events_url":"https://api.github.com/repos/mzhurovich/Sherlock/issues/events{/number}","events_url":"https://api.github.com/repos/mzhurovich/Sherlock/events","assignees_url":"https://api.github.com/repos/mzhurovich/Sherlock/assignees{/user}","branches_url":"https://api.github.com/repos/mzhurovich/Sherlock/branches{/branch}","tags_url":"https://api.github.com/repos/mzhurovich/Sherlock/tags","blobs_url":"https://api.github.com/repos/mzhurovich/Sherlock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mzhurovich/Sherlock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mzhurovich/Sherlock/git/refs{/sha}","trees_url":"https://api.github.com/repos/mzhurovich/Sherlock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mzhurovich/Sherlock/statuses/{sha}","languages_url":"https://api.github.com/repos/mzhurovich/Sherlock/languages","stargazers_url":"https://api.github.com/repos/mzhurovich/Sherlock/stargazers","contributors_url":"https://api.github.com/repos/mzhurovich/Sherlock/contributors","subscribers_url":"https://api.github.com/repos/mzhurovich/Sherlock/subscribers","subscription_url":"https://api.github.com/repos/mzhurovich/Sherlock/subscription","commits_url":"https://api.github.com/repos/mzhurovich/Sherlock/commits{/sha}","git_commits_url":"https://api.github.com/repos/mzhurovich/Sherlock/git/commits{/sha}","comments_url":"https://api.github.com/repos/mzhurovich/Sherlock/comments{/number}","issue_comment_url":"https://api.github.com/repos/mzhurovich/Sherlock/issues/comments{/number}","contents_url":"https://api.github.com/repos/mzhurovich/Sherlock/contents/{+path}","compare_url":"https://api.github.com/repos/mzhurovich/Sherlock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mzhurovich/Sherlock/merges","archive_url":"https://api.github.com/repos/mzhurovich/Sherlock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mzhurovich/Sherlock/downloads","issues_url":"https://api.github.com/repos/mzhurovich/Sherlock/issues{/number}","pulls_url":"https://api.github.com/repos/mzhurovich/Sherlock/pulls{/number}","milestones_url":"https://api.github.com/repos/mzhurovich/Sherlock/milestones{/number}","notifications_url":"https://api.github.com/repos/mzhurovich/Sherlock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mzhurovich/Sherlock/labels{/name}","releases_url":"https://api.github.com/repos/mzhurovich/Sherlock/releases{/id}","created_at":"2015-04-11T20:09:30Z","updated_at":"2015-04-11T20:09:31Z","pushed_at":"2015-04-16T23:27:42Z","git_url":"git://github.com/mzhurovich/Sherlock.git","ssh_url":"git@github.com:mzhurovich/Sherlock.git","clone_url":"https://github.com/mzhurovich/Sherlock.git","svn_url":"https://github.com/mzhurovich/Sherlock","homepage":null,"size":289,"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":"KnowSheet:master","ref":"master","sha":"a44c0445c05492e4a0c075475b3159da05aa4c80","user":{"login":"KnowSheet","id":9897562,"avatar_url":"https://avatars.githubusercontent.com/u/9897562?v=3","gravatar_id":"","url":"https://api.github.com/users/KnowSheet","html_url":"https://github.com/KnowSheet","followers_url":"https://api.github.com/users/KnowSheet/followers","following_url":"https://api.github.com/users/KnowSheet/following{/other_user}","gists_url":"https://api.github.com/users/KnowSheet/gists{/gist_id}","starred_url":"https://api.github.com/users/KnowSheet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KnowSheet/subscriptions","organizations_url":"https://api.github.com/users/KnowSheet/orgs","repos_url":"https://api.github.com/users/KnowSheet/repos","events_url":"https://api.github.com/users/KnowSheet/events{/privacy}","received_events_url":"https://api.github.com/users/KnowSheet/received_events","type":"Organization","site_admin":false},"repo":{"id":31759722,"name":"Sherlock","full_name":"KnowSheet/Sherlock","owner":{"login":"KnowSheet","id":9897562,"avatar_url":"https://avatars.githubusercontent.com/u/9897562?v=3","gravatar_id":"","url":"https://api.github.com/users/KnowSheet","html_url":"https://github.com/KnowSheet","followers_url":"https://api.github.com/users/KnowSheet/followers","following_url":"https://api.github.com/users/KnowSheet/following{/other_user}","gists_url":"https://api.github.com/users/KnowSheet/gists{/gist_id}","starred_url":"https://api.github.com/users/KnowSheet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KnowSheet/subscriptions","organizations_url":"https://api.github.com/users/KnowSheet/orgs","repos_url":"https://api.github.com/users/KnowSheet/repos","events_url":"https://api.github.com/users/KnowSheet/events{/privacy}","received_events_url":"https://api.github.com/users/KnowSheet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/KnowSheet/Sherlock","description":"Structured, append-only, immutable data persistence layer with publish-subscribe.","fork":false,"url":"https://api.github.com/repos/KnowSheet/Sherlock","forks_url":"https://api.github.com/repos/KnowSheet/Sherlock/forks","keys_url":"https://api.github.com/repos/KnowSheet/Sherlock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KnowSheet/Sherlock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KnowSheet/Sherlock/teams","hooks_url":"https://api.github.com/repos/KnowSheet/Sherlock/hooks","issue_events_url":"https://api.github.com/repos/KnowSheet/Sherlock/issues/events{/number}","events_url":"https://api.github.com/repos/KnowSheet/Sherlock/events","assignees_url":"https://api.github.com/repos/KnowSheet/Sherlock/assignees{/user}","branches_url":"https://api.github.com/repos/KnowSheet/Sherlock/branches{/branch}","tags_url":"https://api.github.com/repos/KnowSheet/Sherlock/tags","blobs_url":"https://api.github.com/repos/KnowSheet/Sherlock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KnowSheet/Sherlock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KnowSheet/Sherlock/git/refs{/sha}","trees_url":"https://api.github.com/repos/KnowSheet/Sherlock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KnowSheet/Sherlock/statuses/{sha}","languages_url":"https://api.github.com/repos/KnowSheet/Sherlock/languages","stargazers_url":"https://api.github.com/repos/KnowSheet/Sherlock/stargazers","contributors_url":"https://api.github.com/repos/KnowSheet/Sherlock/contributors","subscribers_url":"https://api.github.com/repos/KnowSheet/Sherlock/subscribers","subscription_url":"https://api.github.com/repos/KnowSheet/Sherlock/subscription","commits_url":"https://api.github.com/repos/KnowSheet/Sherlock/commits{/sha}","git_commits_url":"https://api.github.com/repos/KnowSheet/Sherlock/git/commits{/sha}","comments_url":"https://api.github.com/repos/KnowSheet/Sherlock/comments{/number}","issue_comment_url":"https://api.github.com/repos/KnowSheet/Sherlock/issues/comments{/number}","contents_url":"https://api.github.com/repos/KnowSheet/Sherlock/contents/{+path}","compare_url":"https://api.github.com/repos/KnowSheet/Sherlock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KnowSheet/Sherlock/merges","archive_url":"https://api.github.com/repos/KnowSheet/Sherlock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KnowSheet/Sherlock/downloads","issues_url":"https://api.github.com/repos/KnowSheet/Sherlock/issues{/number}","pulls_url":"https://api.github.com/repos/KnowSheet/Sherlock/pulls{/number}","milestones_url":"https://api.github.com/repos/KnowSheet/Sherlock/milestones{/number}","notifications_url":"https://api.github.com/repos/KnowSheet/Sherlock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KnowSheet/Sherlock/labels{/name}","releases_url":"https://api.github.com/repos/KnowSheet/Sherlock/releases{/id}","created_at":"2015-03-06T08:26:50Z","updated_at":"2015-04-10T17:04:16Z","pushed_at":"2015-04-16T23:30:36Z","git_url":"git://github.com/KnowSheet/Sherlock.git","ssh_url":"git@github.com:KnowSheet/Sherlock.git","clone_url":"https://github.com/KnowSheet/Sherlock.git","svn_url":"https://github.com/KnowSheet/Sherlock","homepage":null,"size":579,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":4,"forks":4,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/15"},"html":{"href":"https://github.com/KnowSheet/Sherlock/pull/15"},"issue":{"href":"https://api.github.com/repos/KnowSheet/Sherlock/issues/15"},"comments":{"href":"https://api.github.com/repos/KnowSheet/Sherlock/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/KnowSheet/Sherlock/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/KnowSheet/Sherlock/statuses/157ee5a7c64803a6877c8ba4e94927a4ab46ccdd"}}}}