{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/comments/191775534","pull_request_review_id":124413578,"id":191775534,"diff_hunk":"@@ -4,4 +4,37 @@\n \n package mozilla.components.service.fretboard\n \n-class Fretboard\n+/**\n+ * Entry point of the library\n+ *\n+ * @param source experiment remote source\n+ * @param storage experiment local storage mechanism\n+ */\n+class Fretboard(\n+    private val source: ExperimentSource,\n+    private val storage: ExperimentStorage\n+) {\n+    internal var experiments: List<Experiment> = listOf()\n+        private set\n+\n+    /**\n+     * Loads experiments from local storage\n+     */\n+    fun loadExperiments() {\n+        experiments = storage.retrieve()\n+    }\n+\n+    /**\n+     * Requests new experiments from the server and\n+     * saves them to local storage\n+     */\n+    fun updateExperiments() {\n+        try {\n+            val serverExperiments = source.getExperiments(experiments)\n+            experiments = serverExperiments\n+            storage.save(serverExperiments)\n+        } catch (e: ExperimentDownloadException) {\n+            // Keep using the local experiments\n+        }","path":"fretboard/src/main/java/mozilla/components/service/fretboard/Fretboard.kt","position":36,"original_position":36,"commit_id":"375629fcd2dfa1b55a814fd85d5b5ee5d83a74bc","original_commit_id":"375629fcd2dfa1b55a814fd85d5b5ee5d83a74bc","user":{"login":"fercarcedo","id":4409856,"avatar_url":"https://avatars0.githubusercontent.com/u/4409856?v=4","gravatar_id":"","url":"https://api.github.com/users/fercarcedo","html_url":"https://github.com/fercarcedo","followers_url":"https://api.github.com/users/fercarcedo/followers","following_url":"https://api.github.com/users/fercarcedo/following{/other_user}","gists_url":"https://api.github.com/users/fercarcedo/gists{/gist_id}","starred_url":"https://api.github.com/users/fercarcedo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fercarcedo/subscriptions","organizations_url":"https://api.github.com/users/fercarcedo/orgs","repos_url":"https://api.github.com/users/fercarcedo/repos","events_url":"https://api.github.com/users/fercarcedo/events{/privacy}","received_events_url":"https://api.github.com/users/fercarcedo/received_events","type":"User","site_admin":false},"body":"Maybe we could add a boolean variable to indicate if it was loaded from disk or not and keep the list non-null","created_at":"2018-05-30T13:51:54Z","updated_at":"2018-05-30T13:51:55Z","html_url":"https://github.com/mozilla-mobile/fretboard/pull/22#discussion_r191775534","pull_request_url":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/22","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/comments/191775534"},"html":{"href":"https://github.com/mozilla-mobile/fretboard/pull/22#discussion_r191775534"},"pull_request":{"href":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/22"}},"in_reply_to_id":191766033},"pull_request":{"url":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/22","id":190370508,"html_url":"https://github.com/mozilla-mobile/fretboard/pull/22","diff_url":"https://github.com/mozilla-mobile/fretboard/pull/22.diff","patch_url":"https://github.com/mozilla-mobile/fretboard/pull/22.patch","issue_url":"https://api.github.com/repos/mozilla-mobile/fretboard/issues/22","number":22,"state":"open","locked":false,"title":"Implement client for loading experiment configuration and save to disk","user":{"login":"fercarcedo","id":4409856,"avatar_url":"https://avatars0.githubusercontent.com/u/4409856?v=4","gravatar_id":"","url":"https://api.github.com/users/fercarcedo","html_url":"https://github.com/fercarcedo","followers_url":"https://api.github.com/users/fercarcedo/followers","following_url":"https://api.github.com/users/fercarcedo/following{/other_user}","gists_url":"https://api.github.com/users/fercarcedo/gists{/gist_id}","starred_url":"https://api.github.com/users/fercarcedo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fercarcedo/subscriptions","organizations_url":"https://api.github.com/users/fercarcedo/orgs","repos_url":"https://api.github.com/users/fercarcedo/repos","events_url":"https://api.github.com/users/fercarcedo/events{/privacy}","received_events_url":"https://api.github.com/users/fercarcedo/received_events","type":"User","site_admin":false},"body":"Implemented client for loading experiment configuration from server and storage mechanism to save the retrieved configuration to disk.\r\n\r\nIn order to be independent of the actual http client being used, I have created an interface `HttpClient`. Also there is an `ExperimentSource` interface which is used to fetch the experiments from a specific source (such as Kinto), parsing the diff response into an actual list of `Experiment`.\r\n\r\nFor the storage part there is an `ExperimentStorage` interface which is used to store and retrieve the downloaded experiment configuration from disk.\r\n\r\nThere are also concrete implementations of these interfaces: an http client based on `HttpURLConnection`, in the `client-httpurlconnection` module, an experiment source for Kinto in the `source-kinto` and a storage mechanism based on `AtomicFile` in the `storage-atomicfile` module.\r\n\r\nAll of these classes have unit tests (except the HttpURLConnection HttpClient, in order for the tests to not depend on a network connection, correct me if I'm wrong :) ), and also the `AtomicFile`-based implementation has an instrumented test to verify the real behavior reading and wrting from disk.\r\n\r\nLast, I have added code to the Fretboard class to let the user configure the library and a method for loading experiments from server, which uses the three interfaces mentioned earlier.\r\n\r\nCloses #3 #4 ","created_at":"2018-05-24T17:51:13Z","updated_at":"2018-05-30T13:51:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"60fe84d953e3156530c45449fee02137377321e0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/22/commits","review_comments_url":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/22/comments","review_comment_url":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-mobile/fretboard/issues/22/comments","statuses_url":"https://api.github.com/repos/mozilla-mobile/fretboard/statuses/375629fcd2dfa1b55a814fd85d5b5ee5d83a74bc","head":{"label":"fercarcedo:experiment-client-storage","ref":"experiment-client-storage","sha":"375629fcd2dfa1b55a814fd85d5b5ee5d83a74bc","user":{"login":"fercarcedo","id":4409856,"avatar_url":"https://avatars0.githubusercontent.com/u/4409856?v=4","gravatar_id":"","url":"https://api.github.com/users/fercarcedo","html_url":"https://github.com/fercarcedo","followers_url":"https://api.github.com/users/fercarcedo/followers","following_url":"https://api.github.com/users/fercarcedo/following{/other_user}","gists_url":"https://api.github.com/users/fercarcedo/gists{/gist_id}","starred_url":"https://api.github.com/users/fercarcedo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fercarcedo/subscriptions","organizations_url":"https://api.github.com/users/fercarcedo/orgs","repos_url":"https://api.github.com/users/fercarcedo/repos","events_url":"https://api.github.com/users/fercarcedo/events{/privacy}","received_events_url":"https://api.github.com/users/fercarcedo/received_events","type":"User","site_admin":false},"repo":{"id":130993928,"name":"fretboard","full_name":"fercarcedo/fretboard","owner":{"login":"fercarcedo","id":4409856,"avatar_url":"https://avatars0.githubusercontent.com/u/4409856?v=4","gravatar_id":"","url":"https://api.github.com/users/fercarcedo","html_url":"https://github.com/fercarcedo","followers_url":"https://api.github.com/users/fercarcedo/followers","following_url":"https://api.github.com/users/fercarcedo/following{/other_user}","gists_url":"https://api.github.com/users/fercarcedo/gists{/gist_id}","starred_url":"https://api.github.com/users/fercarcedo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fercarcedo/subscriptions","organizations_url":"https://api.github.com/users/fercarcedo/orgs","repos_url":"https://api.github.com/users/fercarcedo/repos","events_url":"https://api.github.com/users/fercarcedo/events{/privacy}","received_events_url":"https://api.github.com/users/fercarcedo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fercarcedo/fretboard","description":"A simple A/B testing framework for mobile applications","fork":true,"url":"https://api.github.com/repos/fercarcedo/fretboard","forks_url":"https://api.github.com/repos/fercarcedo/fretboard/forks","keys_url":"https://api.github.com/repos/fercarcedo/fretboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fercarcedo/fretboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fercarcedo/fretboard/teams","hooks_url":"https://api.github.com/repos/fercarcedo/fretboard/hooks","issue_events_url":"https://api.github.com/repos/fercarcedo/fretboard/issues/events{/number}","events_url":"https://api.github.com/repos/fercarcedo/fretboard/events","assignees_url":"https://api.github.com/repos/fercarcedo/fretboard/assignees{/user}","branches_url":"https://api.github.com/repos/fercarcedo/fretboard/branches{/branch}","tags_url":"https://api.github.com/repos/fercarcedo/fretboard/tags","blobs_url":"https://api.github.com/repos/fercarcedo/fretboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fercarcedo/fretboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fercarcedo/fretboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/fercarcedo/fretboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fercarcedo/fretboard/statuses/{sha}","languages_url":"https://api.github.com/repos/fercarcedo/fretboard/languages","stargazers_url":"https://api.github.com/repos/fercarcedo/fretboard/stargazers","contributors_url":"https://api.github.com/repos/fercarcedo/fretboard/contributors","subscribers_url":"https://api.github.com/repos/fercarcedo/fretboard/subscribers","subscription_url":"https://api.github.com/repos/fercarcedo/fretboard/subscription","commits_url":"https://api.github.com/repos/fercarcedo/fretboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/fercarcedo/fretboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/fercarcedo/fretboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/fercarcedo/fretboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/fercarcedo/fretboard/contents/{+path}","compare_url":"https://api.github.com/repos/fercarcedo/fretboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fercarcedo/fretboard/merges","archive_url":"https://api.github.com/repos/fercarcedo/fretboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fercarcedo/fretboard/downloads","issues_url":"https://api.github.com/repos/fercarcedo/fretboard/issues{/number}","pulls_url":"https://api.github.com/repos/fercarcedo/fretboard/pulls{/number}","milestones_url":"https://api.github.com/repos/fercarcedo/fretboard/milestones{/number}","notifications_url":"https://api.github.com/repos/fercarcedo/fretboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fercarcedo/fretboard/labels{/name}","releases_url":"https://api.github.com/repos/fercarcedo/fretboard/releases{/id}","deployments_url":"https://api.github.com/repos/fercarcedo/fretboard/deployments","created_at":"2018-04-25T11:07:37Z","updated_at":"2018-05-24T17:40:44Z","pushed_at":"2018-05-30T10:30:40Z","git_url":"git://github.com/fercarcedo/fretboard.git","ssh_url":"git@github.com:fercarcedo/fretboard.git","clone_url":"https://github.com/fercarcedo/fretboard.git","svn_url":"https://github.com/fercarcedo/fretboard","homepage":null,"size":85,"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":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla-mobile:master","ref":"master","sha":"9fd3e53a65abf2ae1462a9da2f2c854c65c8fed9","user":{"login":"mozilla-mobile","id":22351667,"avatar_url":"https://avatars3.githubusercontent.com/u/22351667?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla-mobile","html_url":"https://github.com/mozilla-mobile","followers_url":"https://api.github.com/users/mozilla-mobile/followers","following_url":"https://api.github.com/users/mozilla-mobile/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-mobile/subscriptions","organizations_url":"https://api.github.com/users/mozilla-mobile/orgs","repos_url":"https://api.github.com/users/mozilla-mobile/repos","events_url":"https://api.github.com/users/mozilla-mobile/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-mobile/received_events","type":"Organization","site_admin":false},"repo":{"id":122958938,"name":"fretboard","full_name":"mozilla-mobile/fretboard","owner":{"login":"mozilla-mobile","id":22351667,"avatar_url":"https://avatars3.githubusercontent.com/u/22351667?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla-mobile","html_url":"https://github.com/mozilla-mobile","followers_url":"https://api.github.com/users/mozilla-mobile/followers","following_url":"https://api.github.com/users/mozilla-mobile/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-mobile/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-mobile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-mobile/subscriptions","organizations_url":"https://api.github.com/users/mozilla-mobile/orgs","repos_url":"https://api.github.com/users/mozilla-mobile/repos","events_url":"https://api.github.com/users/mozilla-mobile/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-mobile/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-mobile/fretboard","description":"A simple A/B testing framework for mobile applications","fork":false,"url":"https://api.github.com/repos/mozilla-mobile/fretboard","forks_url":"https://api.github.com/repos/mozilla-mobile/fretboard/forks","keys_url":"https://api.github.com/repos/mozilla-mobile/fretboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-mobile/fretboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-mobile/fretboard/teams","hooks_url":"https://api.github.com/repos/mozilla-mobile/fretboard/hooks","issue_events_url":"https://api.github.com/repos/mozilla-mobile/fretboard/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-mobile/fretboard/events","assignees_url":"https://api.github.com/repos/mozilla-mobile/fretboard/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-mobile/fretboard/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-mobile/fretboard/tags","blobs_url":"https://api.github.com/repos/mozilla-mobile/fretboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-mobile/fretboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-mobile/fretboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-mobile/fretboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-mobile/fretboard/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-mobile/fretboard/languages","stargazers_url":"https://api.github.com/repos/mozilla-mobile/fretboard/stargazers","contributors_url":"https://api.github.com/repos/mozilla-mobile/fretboard/contributors","subscribers_url":"https://api.github.com/repos/mozilla-mobile/fretboard/subscribers","subscription_url":"https://api.github.com/repos/mozilla-mobile/fretboard/subscription","commits_url":"https://api.github.com/repos/mozilla-mobile/fretboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-mobile/fretboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-mobile/fretboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-mobile/fretboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-mobile/fretboard/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-mobile/fretboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-mobile/fretboard/merges","archive_url":"https://api.github.com/repos/mozilla-mobile/fretboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-mobile/fretboard/downloads","issues_url":"https://api.github.com/repos/mozilla-mobile/fretboard/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-mobile/fretboard/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-mobile/fretboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-mobile/fretboard/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-mobile/fretboard/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla-mobile/fretboard/deployments","created_at":"2018-02-26T11:15:40Z","updated_at":"2018-05-29T16:55:57Z","pushed_at":"2018-05-30T10:30:42Z","git_url":"git://github.com/mozilla-mobile/fretboard.git","ssh_url":"git@github.com:mozilla-mobile/fretboard.git","clone_url":"https://github.com/mozilla-mobile/fretboard.git","svn_url":"https://github.com/mozilla-mobile/fretboard","homepage":null,"size":68,"stargazers_count":2,"watchers_count":2,"language":"Kotlin","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":3,"open_issues":15,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/22"},"html":{"href":"https://github.com/mozilla-mobile/fretboard/pull/22"},"issue":{"href":"https://api.github.com/repos/mozilla-mobile/fretboard/issues/22"},"comments":{"href":"https://api.github.com/repos/mozilla-mobile/fretboard/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-mobile/fretboard/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-mobile/fretboard/statuses/375629fcd2dfa1b55a814fd85d5b5ee5d83a74bc"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"fercarcedo"}}