{"action":"created","comment":{"url":"https://api.github.com/repos/clouway/kcqrs/pulls/comments/199087477","pull_request_review_id":133137686,"id":199087477,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTA4NzQ3Nw==","diff_hunk":"@@ -84,11 +110,23 @@ class AppEngineEventStore(private val kind: String = \"Event\", private val messag\n \n             aggregateEntity.setUnindexedProperty(eventsProperty, aggregateEvents)\n             aggregateEntity.setUnindexedProperty(versionProperty, currentVersion + events.size)\n-            dataStore.put(transaction, listOf(snapshot, aggregateEntity))\n-\n-            transaction.commit()\n+            return try {\n+                dataStore.put(transaction, listOf(snapshotEntity, aggregateEntity))\n+                transaction.commit()\n+                SaveEventsResponse.Success(aggregateId, currentVersion)\n+            } catch (ex: ApiProxy.RequestTooLargeException) {\n+                var snapshot: Snapshot? = null\n+                //if a build snapshot does not exist it would not have the field data filled in.\n+                if (snapshotEntity.getProperty(\"data\") as Blob? != null) {","path":"kcqrs-appengine/src/main/kotlin/com/clouway/kcqrs/adapter/appengine/AppEngineEventStore.kt","position":67,"original_position":67,"commit_id":"fefcff2305ba89fad38b45b354e0ad9f5ac6e642","original_commit_id":"fefcff2305ba89fad38b45b354e0ad9f5ac6e642","user":{"login":"VasilMitovClouway","id":18255988,"node_id":"MDQ6VXNlcjE4MjU1OTg4","avatar_url":"https://avatars3.githubusercontent.com/u/18255988?v=4","gravatar_id":"","url":"https://api.github.com/users/VasilMitovClouway","html_url":"https://github.com/VasilMitovClouway","followers_url":"https://api.github.com/users/VasilMitovClouway/followers","following_url":"https://api.github.com/users/VasilMitovClouway/following{/other_user}","gists_url":"https://api.github.com/users/VasilMitovClouway/gists{/gist_id}","starred_url":"https://api.github.com/users/VasilMitovClouway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VasilMitovClouway/subscriptions","organizations_url":"https://api.github.com/users/VasilMitovClouway/orgs","repos_url":"https://api.github.com/users/VasilMitovClouway/repos","events_url":"https://api.github.com/users/VasilMitovClouway/events{/privacy}","received_events_url":"https://api.github.com/users/VasilMitovClouway/received_events","type":"User","site_admin":false},"body":"The workflow is as follows The aggregate repository tries to save an entity (e.g add the new events) \r\nthe EventStore returns that it has reached it's limit with an SaveEventsResponse.CurrentEventsLimitReached\r\n```Kotlin \r\ndata class CurrentEventsLimitReached(val currentEvents: List<EventPayload>, val currentSnapshot: Snapshot? = null) : SaveEventsResponse()\r\n```\r\nAs i see the object is build from the events in the SimpleAggregateRepository, that's why i've chosen to return the current events and a snapshot if available back to the SimpleAggregateRepository. \r\nThe fact that the current events limit has been reached prompts the SimpleAggregateRepository to retry it's request with the same SaveOptions but including a new setting \r\n\r\n```Kotlin\r\ndata class CreateSnapshot(val required: Boolean = false, val snapshotData: String = \"\")\r\n```\r\nwith required set to true and the newly build snapshot.\r\n\r\nCould be optimized with the snapshotData being a byte array altogether. \r\n\r\nThe new snapshot is being build from the old snapshot ( if available) and the current events that have reached their limit but without the new ones. This way the new events will not by digested in the new snapshot and will be present in the new entity ( or whatever persistence we have chosen)\r\n\r\nThen sending the new snapshot with the events that caused the event limit reach and saving them in a new entity. \r\n\r\nThis way the SimpleAggregateRepository retries the save of the events by itself and manages the snapshot creation. \r\n","created_at":"2018-06-29T08:22:08Z","updated_at":"2018-06-29T08:22:08Z","html_url":"https://github.com/clouway/kcqrs/pull/33#discussion_r199087477","pull_request_url":"https://api.github.com/repos/clouway/kcqrs/pulls/33","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/clouway/kcqrs/pulls/comments/199087477"},"html":{"href":"https://github.com/clouway/kcqrs/pull/33#discussion_r199087477"},"pull_request":{"href":"https://api.github.com/repos/clouway/kcqrs/pulls/33"}},"in_reply_to_id":198912262},"pull_request":{"url":"https://api.github.com/repos/clouway/kcqrs/pulls/33","id":198073847,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4MDczODQ3","html_url":"https://github.com/clouway/kcqrs/pull/33","diff_url":"https://github.com/clouway/kcqrs/pull/33.diff","patch_url":"https://github.com/clouway/kcqrs/pull/33.patch","issue_url":"https://api.github.com/repos/clouway/kcqrs/issues/33","number":33,"state":"open","locked":false,"title":"kcqrs: implement Snapshots","user":{"login":"VasilMitovClouway","id":18255988,"node_id":"MDQ6VXNlcjE4MjU1OTg4","avatar_url":"https://avatars3.githubusercontent.com/u/18255988?v=4","gravatar_id":"","url":"https://api.github.com/users/VasilMitovClouway","html_url":"https://github.com/VasilMitovClouway","followers_url":"https://api.github.com/users/VasilMitovClouway/followers","following_url":"https://api.github.com/users/VasilMitovClouway/following{/other_user}","gists_url":"https://api.github.com/users/VasilMitovClouway/gists{/gist_id}","starred_url":"https://api.github.com/users/VasilMitovClouway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VasilMitovClouway/subscriptions","organizations_url":"https://api.github.com/users/VasilMitovClouway/orgs","repos_url":"https://api.github.com/users/VasilMitovClouway/repos","events_url":"https://api.github.com/users/VasilMitovClouway/events{/privacy}","received_events_url":"https://api.github.com/users/VasilMitovClouway/received_events","type":"User","site_admin":false},"body":"Work in progress.\r\nFixes:  #11","created_at":"2018-06-28T15:46:09Z","updated_at":"2018-06-29T08:22:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"834e8172db8981406660191e0ede7f84416c650a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/clouway/kcqrs/pulls/33/commits","review_comments_url":"https://api.github.com/repos/clouway/kcqrs/pulls/33/comments","review_comment_url":"https://api.github.com/repos/clouway/kcqrs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/clouway/kcqrs/issues/33/comments","statuses_url":"https://api.github.com/repos/clouway/kcqrs/statuses/fefcff2305ba89fad38b45b354e0ad9f5ac6e642","head":{"label":"VasilMitovClouway:snapshot_implementation","ref":"snapshot_implementation","sha":"fefcff2305ba89fad38b45b354e0ad9f5ac6e642","user":{"login":"VasilMitovClouway","id":18255988,"node_id":"MDQ6VXNlcjE4MjU1OTg4","avatar_url":"https://avatars3.githubusercontent.com/u/18255988?v=4","gravatar_id":"","url":"https://api.github.com/users/VasilMitovClouway","html_url":"https://github.com/VasilMitovClouway","followers_url":"https://api.github.com/users/VasilMitovClouway/followers","following_url":"https://api.github.com/users/VasilMitovClouway/following{/other_user}","gists_url":"https://api.github.com/users/VasilMitovClouway/gists{/gist_id}","starred_url":"https://api.github.com/users/VasilMitovClouway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VasilMitovClouway/subscriptions","organizations_url":"https://api.github.com/users/VasilMitovClouway/orgs","repos_url":"https://api.github.com/users/VasilMitovClouway/repos","events_url":"https://api.github.com/users/VasilMitovClouway/events{/privacy}","received_events_url":"https://api.github.com/users/VasilMitovClouway/received_events","type":"User","site_admin":false},"repo":{"id":120425446,"node_id":"MDEwOlJlcG9zaXRvcnkxMjA0MjU0NDY=","name":"kcqrs","full_name":"VasilMitovClouway/kcqrs","owner":{"login":"VasilMitovClouway","id":18255988,"node_id":"MDQ6VXNlcjE4MjU1OTg4","avatar_url":"https://avatars3.githubusercontent.com/u/18255988?v=4","gravatar_id":"","url":"https://api.github.com/users/VasilMitovClouway","html_url":"https://github.com/VasilMitovClouway","followers_url":"https://api.github.com/users/VasilMitovClouway/followers","following_url":"https://api.github.com/users/VasilMitovClouway/following{/other_user}","gists_url":"https://api.github.com/users/VasilMitovClouway/gists{/gist_id}","starred_url":"https://api.github.com/users/VasilMitovClouway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VasilMitovClouway/subscriptions","organizations_url":"https://api.github.com/users/VasilMitovClouway/orgs","repos_url":"https://api.github.com/users/VasilMitovClouway/repos","events_url":"https://api.github.com/users/VasilMitovClouway/events{/privacy}","received_events_url":"https://api.github.com/users/VasilMitovClouway/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/VasilMitovClouway/kcqrs","description":"kcqrs - a cqrs made easy with kotlin","fork":true,"url":"https://api.github.com/repos/VasilMitovClouway/kcqrs","forks_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/forks","keys_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/teams","hooks_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/hooks","issue_events_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/issues/events{/number}","events_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/events","assignees_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/assignees{/user}","branches_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/branches{/branch}","tags_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/tags","blobs_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/git/refs{/sha}","trees_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/statuses/{sha}","languages_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/languages","stargazers_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/stargazers","contributors_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/contributors","subscribers_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/subscribers","subscription_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/subscription","commits_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/commits{/sha}","git_commits_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/git/commits{/sha}","comments_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/comments{/number}","issue_comment_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/issues/comments{/number}","contents_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/contents/{+path}","compare_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/merges","archive_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/downloads","issues_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/issues{/number}","pulls_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/pulls{/number}","milestones_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/milestones{/number}","notifications_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/labels{/name}","releases_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/releases{/id}","deployments_url":"https://api.github.com/repos/VasilMitovClouway/kcqrs/deployments","created_at":"2018-02-06T08:37:48Z","updated_at":"2018-02-06T08:37:50Z","pushed_at":"2018-06-28T15:45:36Z","git_url":"git://github.com/VasilMitovClouway/kcqrs.git","ssh_url":"git@github.com:VasilMitovClouway/kcqrs.git","clone_url":"https://github.com/VasilMitovClouway/kcqrs.git","svn_url":"https://github.com/VasilMitovClouway/kcqrs","homepage":null,"size":268,"stargazers_count":0,"watchers_count":0,"language":"Kotlin","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"clouway:master","ref":"master","sha":"c31c2e4fc3910b2f60e295f4781a0fcc6e18d200","user":{"login":"clouway","id":1746331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NDYzMzE=","avatar_url":"https://avatars2.githubusercontent.com/u/1746331?v=4","gravatar_id":"","url":"https://api.github.com/users/clouway","html_url":"https://github.com/clouway","followers_url":"https://api.github.com/users/clouway/followers","following_url":"https://api.github.com/users/clouway/following{/other_user}","gists_url":"https://api.github.com/users/clouway/gists{/gist_id}","starred_url":"https://api.github.com/users/clouway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clouway/subscriptions","organizations_url":"https://api.github.com/users/clouway/orgs","repos_url":"https://api.github.com/users/clouway/repos","events_url":"https://api.github.com/users/clouway/events{/privacy}","received_events_url":"https://api.github.com/users/clouway/received_events","type":"Organization","site_admin":false},"repo":{"id":108405381,"node_id":"MDEwOlJlcG9zaXRvcnkxMDg0MDUzODE=","name":"kcqrs","full_name":"clouway/kcqrs","owner":{"login":"clouway","id":1746331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NDYzMzE=","avatar_url":"https://avatars2.githubusercontent.com/u/1746331?v=4","gravatar_id":"","url":"https://api.github.com/users/clouway","html_url":"https://github.com/clouway","followers_url":"https://api.github.com/users/clouway/followers","following_url":"https://api.github.com/users/clouway/following{/other_user}","gists_url":"https://api.github.com/users/clouway/gists{/gist_id}","starred_url":"https://api.github.com/users/clouway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clouway/subscriptions","organizations_url":"https://api.github.com/users/clouway/orgs","repos_url":"https://api.github.com/users/clouway/repos","events_url":"https://api.github.com/users/clouway/events{/privacy}","received_events_url":"https://api.github.com/users/clouway/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clouway/kcqrs","description":"kcqrs - a cqrs made easy with kotlin","fork":false,"url":"https://api.github.com/repos/clouway/kcqrs","forks_url":"https://api.github.com/repos/clouway/kcqrs/forks","keys_url":"https://api.github.com/repos/clouway/kcqrs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clouway/kcqrs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clouway/kcqrs/teams","hooks_url":"https://api.github.com/repos/clouway/kcqrs/hooks","issue_events_url":"https://api.github.com/repos/clouway/kcqrs/issues/events{/number}","events_url":"https://api.github.com/repos/clouway/kcqrs/events","assignees_url":"https://api.github.com/repos/clouway/kcqrs/assignees{/user}","branches_url":"https://api.github.com/repos/clouway/kcqrs/branches{/branch}","tags_url":"https://api.github.com/repos/clouway/kcqrs/tags","blobs_url":"https://api.github.com/repos/clouway/kcqrs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clouway/kcqrs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clouway/kcqrs/git/refs{/sha}","trees_url":"https://api.github.com/repos/clouway/kcqrs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clouway/kcqrs/statuses/{sha}","languages_url":"https://api.github.com/repos/clouway/kcqrs/languages","stargazers_url":"https://api.github.com/repos/clouway/kcqrs/stargazers","contributors_url":"https://api.github.com/repos/clouway/kcqrs/contributors","subscribers_url":"https://api.github.com/repos/clouway/kcqrs/subscribers","subscription_url":"https://api.github.com/repos/clouway/kcqrs/subscription","commits_url":"https://api.github.com/repos/clouway/kcqrs/commits{/sha}","git_commits_url":"https://api.github.com/repos/clouway/kcqrs/git/commits{/sha}","comments_url":"https://api.github.com/repos/clouway/kcqrs/comments{/number}","issue_comment_url":"https://api.github.com/repos/clouway/kcqrs/issues/comments{/number}","contents_url":"https://api.github.com/repos/clouway/kcqrs/contents/{+path}","compare_url":"https://api.github.com/repos/clouway/kcqrs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clouway/kcqrs/merges","archive_url":"https://api.github.com/repos/clouway/kcqrs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clouway/kcqrs/downloads","issues_url":"https://api.github.com/repos/clouway/kcqrs/issues{/number}","pulls_url":"https://api.github.com/repos/clouway/kcqrs/pulls{/number}","milestones_url":"https://api.github.com/repos/clouway/kcqrs/milestones{/number}","notifications_url":"https://api.github.com/repos/clouway/kcqrs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clouway/kcqrs/labels{/name}","releases_url":"https://api.github.com/repos/clouway/kcqrs/releases{/id}","deployments_url":"https://api.github.com/repos/clouway/kcqrs/deployments","created_at":"2017-10-26T11:58:28Z","updated_at":"2018-06-20T11:59:23Z","pushed_at":"2018-06-28T15:46:09Z","git_url":"git://github.com/clouway/kcqrs.git","ssh_url":"git@github.com:clouway/kcqrs.git","clone_url":"https://github.com/clouway/kcqrs.git","svn_url":"https://github.com/clouway/kcqrs","homepage":null,"size":254,"stargazers_count":3,"watchers_count":3,"language":"Kotlin","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":6,"open_issues":10,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clouway/kcqrs/pulls/33"},"html":{"href":"https://github.com/clouway/kcqrs/pull/33"},"issue":{"href":"https://api.github.com/repos/clouway/kcqrs/issues/33"},"comments":{"href":"https://api.github.com/repos/clouway/kcqrs/issues/33/comments"},"review_comments":{"href":"https://api.github.com/repos/clouway/kcqrs/pulls/33/comments"},"review_comment":{"href":"https://api.github.com/repos/clouway/kcqrs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/clouway/kcqrs/pulls/33/commits"},"statuses":{"href":"https://api.github.com/repos/clouway/kcqrs/statuses/fefcff2305ba89fad38b45b354e0ad9f5ac6e642"}},"author_association":"NONE"}}
{"actor":{"display_login":"VasilMitovClouway"}}