{"action":"created","comment":{"url":"https://api.github.com/repos/Shopify/semian/pulls/comments/44550838","id":44550838,"diff_hunk":"@@ -0,0 +1,29 @@\n+module Semian\n+  module Simple\n+    class Enum #:nodoc:\n+      def initialize(symbol_list:)\n+        @allowed_symbols = symbol_list\n+        reset\n+      end\n+\n+      attr_reader :value\n+\n+      def value=(sym)\n+        raise ArgumentError unless @allowed_symbols.include?(sym)\n+        @value = sym\n+      end\n+\n+      def increment(val = 1)\n+        @value = @allowed_symbols[(@allowed_symbols.index(@value) + val) % @allowed_symbols.size]\n+      end","path":"lib/semian/simple_enum.rb","position":18,"original_position":18,"commit_id":"7e1e6ff691af3e07acd704b40937dc3e201929ea","original_commit_id":"32f68ad1b8e08344126284a245788e0eefe130a9","user":{"login":"Sirupsen","id":97400,"avatar_url":"https://avatars.githubusercontent.com/u/97400?v=3","gravatar_id":"","url":"https://api.github.com/users/Sirupsen","html_url":"https://github.com/Sirupsen","followers_url":"https://api.github.com/users/Sirupsen/followers","following_url":"https://api.github.com/users/Sirupsen/following{/other_user}","gists_url":"https://api.github.com/users/Sirupsen/gists{/gist_id}","starred_url":"https://api.github.com/users/Sirupsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sirupsen/subscriptions","organizations_url":"https://api.github.com/users/Sirupsen/orgs","repos_url":"https://api.github.com/users/Sirupsen/repos","events_url":"https://api.github.com/users/Sirupsen/events{/privacy}","received_events_url":"https://api.github.com/users/Sirupsen/received_events","type":"User","site_admin":false},"body":"I think `[:closed, :open, :half_open]`, you can only iterate forwards, but you can wrap around. Tests should confirm this.","created_at":"2015-11-11T16:18:56Z","updated_at":"2015-11-11T16:18:56Z","html_url":"https://github.com/Shopify/semian/pull/62#discussion_r44550838","pull_request_url":"https://api.github.com/repos/Shopify/semian/pulls/62","_links":{"self":{"href":"https://api.github.com/repos/Shopify/semian/pulls/comments/44550838"},"html":{"href":"https://github.com/Shopify/semian/pull/62#discussion_r44550838"},"pull_request":{"href":"https://api.github.com/repos/Shopify/semian/pulls/62"}}},"pull_request":{"url":"https://api.github.com/repos/Shopify/semian/pulls/62","id":50314745,"html_url":"https://github.com/Shopify/semian/pull/62","diff_url":"https://github.com/Shopify/semian/pull/62.diff","patch_url":"https://github.com/Shopify/semian/pull/62.patch","issue_url":"https://api.github.com/repos/Shopify/semian/issues/62","number":62,"state":"open","locked":false,"title":"Extracted CircuitBreaker states into 3 structures","user":{"login":"kyewei","id":4326799,"avatar_url":"https://avatars.githubusercontent.com/u/4326799?v=3","gravatar_id":"","url":"https://api.github.com/users/kyewei","html_url":"https://github.com/kyewei","followers_url":"https://api.github.com/users/kyewei/followers","following_url":"https://api.github.com/users/kyewei/following{/other_user}","gists_url":"https://api.github.com/users/kyewei/gists{/gist_id}","starred_url":"https://api.github.com/users/kyewei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyewei/subscriptions","organizations_url":"https://api.github.com/users/kyewei/orgs","repos_url":"https://api.github.com/users/kyewei/repos","events_url":"https://api.github.com/users/kyewei/events{/privacy}","received_events_url":"https://api.github.com/users/kyewei/received_events","type":"User","site_admin":false},"body":"Older closed PR is this: https://github.com/Shopify/semian/pull/56\r\nEven older massive PR that we're trying to split is this (probably a bit outdated by this point): https://github.com/Shopify/semian/pull/54\r\n\r\nThree structures are for holding the `@success`, `@state`, and `@sliding_window` of the `CircuitBreaker` class. \r\n\r\nThey are now under `Semian::Simple`, and future SysV implementation will be under `Semian::SysV`. \r\n\r\nIssue that came up and may/may not have been addressed: \r\n\r\n* For methods in the classes that explicitly return `self` as the last line, its so things like `#<<` don't expose the inner array and leak the implementation, and instead return the appropriate wrapper class. Cascading still works: `wrapper_class_instance << 1 << 2`\r\n* The `Atomic` prefix was removed since it is misleading, and we probably won't be providing a `Mutex` or `Monitor`\r\n* it was suggested to rename the enum type from `Semian::Simple::Enum` to `Semian::Simple::State` and be specialized for the three possible items: `:open`, `:closed`, `:half_open`. Similarly, also rename from `Integer` to `SuccessCount`. **I haven't changed it to those names yet**, since it requires removing some code and makes some of the code a bit weird.\r\n * Pro: specialized, more simple \r\n * Con: naming would definitely be weird, even if the in-memory version from `Simple` stores the values directly, the `SysV` enum type delegates the shared-ness to the `SysV` integer type, and would need to keep a `SysV::SuccessCount` type in the `SysV::State` if we use those names. \r\n* A bit looking into the future, but with the `SysV` versions of the structure needing permissions and a name, `Semian::Simple::SlidingWindow.new(max_size: 4)` and `Semian::SysV::SlidingWindow.new(max_size: 4, permissions: 0660, name: \"sample_int\")` have different interfaces. Ways to solve\r\n * do `def initialize(max_size: , **_)`\r\n * do `def initialize(options = {})` or something of the sort\r\n * not pass in `permissions` and `name` at all, but they have to come from somewhere else without leaking the implementation, possible from `Semian.register`\r\n* The enum class has an `#increment` because it was suggested that it could be used to iterate through the enums. May/may not be needed.\r\n* Slightly extraneous: it was previously mentioned that test suite naming is a bit off, for example `TestCircuitBreaker` is `circuit_breaker_test.rb`\r\n","created_at":"2015-11-10T21:37:12Z","updated_at":"2015-11-11T16:18:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93dd771fa67ff19dc6734d82f0ec49e7e024df04","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Shopify/semian/pulls/62/commits","review_comments_url":"https://api.github.com/repos/Shopify/semian/pulls/62/comments","review_comment_url":"https://api.github.com/repos/Shopify/semian/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shopify/semian/issues/62/comments","statuses_url":"https://api.github.com/repos/Shopify/semian/statuses/7e1e6ff691af3e07acd704b40937dc3e201929ea","head":{"label":"Shopify:separate_cb_structures","ref":"separate_cb_structures","sha":"7e1e6ff691af3e07acd704b40937dc3e201929ea","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":24375548,"name":"semian","full_name":"Shopify/semian","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/semian","description":":monkey: Resiliency toolkit for Ruby for failing fast","fork":false,"url":"https://api.github.com/repos/Shopify/semian","forks_url":"https://api.github.com/repos/Shopify/semian/forks","keys_url":"https://api.github.com/repos/Shopify/semian/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/semian/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/semian/teams","hooks_url":"https://api.github.com/repos/Shopify/semian/hooks","issue_events_url":"https://api.github.com/repos/Shopify/semian/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/semian/events","assignees_url":"https://api.github.com/repos/Shopify/semian/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/semian/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/semian/tags","blobs_url":"https://api.github.com/repos/Shopify/semian/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/semian/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/semian/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/semian/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/semian/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/semian/languages","stargazers_url":"https://api.github.com/repos/Shopify/semian/stargazers","contributors_url":"https://api.github.com/repos/Shopify/semian/contributors","subscribers_url":"https://api.github.com/repos/Shopify/semian/subscribers","subscription_url":"https://api.github.com/repos/Shopify/semian/subscription","commits_url":"https://api.github.com/repos/Shopify/semian/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/semian/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/semian/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/semian/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/semian/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/semian/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/semian/merges","archive_url":"https://api.github.com/repos/Shopify/semian/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/semian/downloads","issues_url":"https://api.github.com/repos/Shopify/semian/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/semian/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/semian/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/semian/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/semian/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/semian/releases{/id}","created_at":"2014-09-23T14:47:19Z","updated_at":"2015-11-11T03:33:17Z","pushed_at":"2015-11-11T15:53:59Z","git_url":"git://github.com/Shopify/semian.git","ssh_url":"git@github.com:Shopify/semian.git","clone_url":"https://github.com/Shopify/semian.git","svn_url":"https://github.com/Shopify/semian","homepage":"","size":1246,"stargazers_count":199,"watchers_count":199,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":16,"forks":10,"open_issues":16,"watchers":199,"default_branch":"master"}},"base":{"label":"Shopify:master","ref":"master","sha":"b97aee80e43c9f4ad35ff95baf6e01c61f91999f","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":24375548,"name":"semian","full_name":"Shopify/semian","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/semian","description":":monkey: Resiliency toolkit for Ruby for failing fast","fork":false,"url":"https://api.github.com/repos/Shopify/semian","forks_url":"https://api.github.com/repos/Shopify/semian/forks","keys_url":"https://api.github.com/repos/Shopify/semian/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/semian/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/semian/teams","hooks_url":"https://api.github.com/repos/Shopify/semian/hooks","issue_events_url":"https://api.github.com/repos/Shopify/semian/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/semian/events","assignees_url":"https://api.github.com/repos/Shopify/semian/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/semian/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/semian/tags","blobs_url":"https://api.github.com/repos/Shopify/semian/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/semian/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/semian/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/semian/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/semian/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/semian/languages","stargazers_url":"https://api.github.com/repos/Shopify/semian/stargazers","contributors_url":"https://api.github.com/repos/Shopify/semian/contributors","subscribers_url":"https://api.github.com/repos/Shopify/semian/subscribers","subscription_url":"https://api.github.com/repos/Shopify/semian/subscription","commits_url":"https://api.github.com/repos/Shopify/semian/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/semian/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/semian/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/semian/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/semian/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/semian/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/semian/merges","archive_url":"https://api.github.com/repos/Shopify/semian/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/semian/downloads","issues_url":"https://api.github.com/repos/Shopify/semian/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/semian/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/semian/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/semian/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/semian/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/semian/releases{/id}","created_at":"2014-09-23T14:47:19Z","updated_at":"2015-11-11T03:33:17Z","pushed_at":"2015-11-11T15:53:59Z","git_url":"git://github.com/Shopify/semian.git","ssh_url":"git@github.com:Shopify/semian.git","clone_url":"https://github.com/Shopify/semian.git","svn_url":"https://github.com/Shopify/semian","homepage":"","size":1246,"stargazers_count":199,"watchers_count":199,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":16,"forks":10,"open_issues":16,"watchers":199,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shopify/semian/pulls/62"},"html":{"href":"https://github.com/Shopify/semian/pull/62"},"issue":{"href":"https://api.github.com/repos/Shopify/semian/issues/62"},"comments":{"href":"https://api.github.com/repos/Shopify/semian/issues/62/comments"},"review_comments":{"href":"https://api.github.com/repos/Shopify/semian/pulls/62/comments"},"review_comment":{"href":"https://api.github.com/repos/Shopify/semian/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shopify/semian/pulls/62/commits"},"statuses":{"href":"https://api.github.com/repos/Shopify/semian/statuses/7e1e6ff691af3e07acd704b40937dc3e201929ea"}}}}