{"action":"created","comment":{"url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/comments/205613559","pull_request_review_id":140922226,"id":205613559,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTYxMzU1OQ==","diff_hunk":"@@ -0,0 +1,70 @@\n+from microcosm_pubsub.chain.context import SafeContext\n+from microcosm_pubsub.chain.context_decorators import (\n+    get_from_context,\n+    save_to_context,\n+    save_to_context_by_func_name,\n+    temporarily_replace_context_keys,\n+)\n+\n+\n+class Chain:\n+    \"\"\"\n+    Structure that contains callable functions that shares the same context.\n+\n+    \"\"\"\n+    def __init__(self, *args):\n+        \"\"\"\n+        Build a chain that can be resolved multiple times\n+        :param *args: callable functions, Chain statemnts or other Chains\n+\n+        \"\"\"\n+        self.links = list(args)\n+\n+    @property\n+    def context_decorators(self):\n+        \"\"\"\n+        Decorators to apply to the chain links\n+\n+        \"\"\"\n+        return [\n+            # Order matter - get_from_context should be first\n+            get_from_context,\n+            temporarily_replace_context_keys,\n+            save_to_context,\n+            save_to_context_by_func_name,\n+        ]\n+\n+    def create_context(self):\n+        \"\"\"\n+        Context to create\n+\n+        \"\"\"\n+        return SafeContext()\n+\n+    def __call__(self, context=None, **kwargs):\n+        \"\"\"\n+        Resolve the chain and return the last chain function result\n+        :param context: use existing context instead of creating a new one\n+        :param **kwargs: initialize the context with some values\n+\n+        \"\"\"\n+        context = context or self.create_context()\n+\n+        for key, value in kwargs.items():\n+            context[key] = value\n+\n+        # Allow self refrence","path":"microcosm_pubsub/chain/chain.py","position":56,"original_position":56,"commit_id":"d9e0a5619acc156eab2b333e6ebc0aa2772142ce","original_commit_id":"d9e0a5619acc156eab2b333e6ebc0aa2772142ce","user":{"login":"jessemyers","id":477722,"node_id":"MDQ6VXNlcjQ3NzcyMg==","avatar_url":"https://avatars0.githubusercontent.com/u/477722?v=4","gravatar_id":"","url":"https://api.github.com/users/jessemyers","html_url":"https://github.com/jessemyers","followers_url":"https://api.github.com/users/jessemyers/followers","following_url":"https://api.github.com/users/jessemyers/following{/other_user}","gists_url":"https://api.github.com/users/jessemyers/gists{/gist_id}","starred_url":"https://api.github.com/users/jessemyers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessemyers/subscriptions","organizations_url":"https://api.github.com/users/jessemyers/orgs","repos_url":"https://api.github.com/users/jessemyers/repos","events_url":"https://api.github.com/users/jessemyers/events{/privacy}","received_events_url":"https://api.github.com/users/jessemyers/received_events","type":"User","site_admin":false},"body":"spelling: reference","created_at":"2018-07-26T21:50:01Z","updated_at":"2018-07-26T21:50:02Z","html_url":"https://github.com/globality-corp/microcosm-pubsub/pull/88#discussion_r205613559","pull_request_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/88","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/comments/205613559"},"html":{"href":"https://github.com/globality-corp/microcosm-pubsub/pull/88#discussion_r205613559"},"pull_request":{"href":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/88"}}},"pull_request":{"url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/88","id":203668106,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzNjY4MTA2","html_url":"https://github.com/globality-corp/microcosm-pubsub/pull/88","diff_url":"https://github.com/globality-corp/microcosm-pubsub/pull/88.diff","patch_url":"https://github.com/globality-corp/microcosm-pubsub/pull/88.patch","issue_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/issues/88","number":88,"state":"open","locked":false,"title":"ChainHandlers","user":{"login":"pelegdvir","id":15822443,"node_id":"MDQ6VXNlcjE1ODIyNDQz","avatar_url":"https://avatars3.githubusercontent.com/u/15822443?v=4","gravatar_id":"","url":"https://api.github.com/users/pelegdvir","html_url":"https://github.com/pelegdvir","followers_url":"https://api.github.com/users/pelegdvir/followers","following_url":"https://api.github.com/users/pelegdvir/following{/other_user}","gists_url":"https://api.github.com/users/pelegdvir/gists{/gist_id}","starred_url":"https://api.github.com/users/pelegdvir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pelegdvir/subscriptions","organizations_url":"https://api.github.com/users/pelegdvir/orgs","repos_url":"https://api.github.com/users/pelegdvir/repos","events_url":"https://api.github.com/users/pelegdvir/events{/privacy}","received_events_url":"https://api.github.com/users/pelegdvir/received_events","type":"User","site_admin":false},"body":"Linear approach for handlers:\r\n* Chain - structure that contains callable functions that shares the same context. Can resolved multiple times with different context (dict) or with a shared one\r\n* ChainHandler - simple handler that resolves the chain with the received message\r\n* ChainUriHandler - uri handler that resolves the chain with the received message and retrieved resource\r\n\r\nSee also globality TD\r\n\r\nMissing:\r\nIntrospection and validation chain methods are not here yet - but can easily be added.","created_at":"2018-07-24T22:04:07Z","updated_at":"2018-07-26T21:50:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ee788676750ad46b22f5905655d35addbeb554f7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/88/commits","review_comments_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/88/comments","review_comment_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/comments{/number}","comments_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/issues/88/comments","statuses_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/statuses/d9e0a5619acc156eab2b333e6ebc0aa2772142ce","head":{"label":"globality-corp:feature/ChainHandler","ref":"feature/ChainHandler","sha":"d9e0a5619acc156eab2b333e6ebc0aa2772142ce","user":{"login":"globality-corp","id":11172782,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMTcyNzgy","avatar_url":"https://avatars2.githubusercontent.com/u/11172782?v=4","gravatar_id":"","url":"https://api.github.com/users/globality-corp","html_url":"https://github.com/globality-corp","followers_url":"https://api.github.com/users/globality-corp/followers","following_url":"https://api.github.com/users/globality-corp/following{/other_user}","gists_url":"https://api.github.com/users/globality-corp/gists{/gist_id}","starred_url":"https://api.github.com/users/globality-corp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/globality-corp/subscriptions","organizations_url":"https://api.github.com/users/globality-corp/orgs","repos_url":"https://api.github.com/users/globality-corp/repos","events_url":"https://api.github.com/users/globality-corp/events{/privacy}","received_events_url":"https://api.github.com/users/globality-corp/received_events","type":"Organization","site_admin":false},"repo":{"id":54516201,"node_id":"MDEwOlJlcG9zaXRvcnk1NDUxNjIwMQ==","name":"microcosm-pubsub","full_name":"globality-corp/microcosm-pubsub","owner":{"login":"globality-corp","id":11172782,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMTcyNzgy","avatar_url":"https://avatars2.githubusercontent.com/u/11172782?v=4","gravatar_id":"","url":"https://api.github.com/users/globality-corp","html_url":"https://github.com/globality-corp","followers_url":"https://api.github.com/users/globality-corp/followers","following_url":"https://api.github.com/users/globality-corp/following{/other_user}","gists_url":"https://api.github.com/users/globality-corp/gists{/gist_id}","starred_url":"https://api.github.com/users/globality-corp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/globality-corp/subscriptions","organizations_url":"https://api.github.com/users/globality-corp/orgs","repos_url":"https://api.github.com/users/globality-corp/repos","events_url":"https://api.github.com/users/globality-corp/events{/privacy}","received_events_url":"https://api.github.com/users/globality-corp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/globality-corp/microcosm-pubsub","description":"PubSub with SNS/SQS","fork":false,"url":"https://api.github.com/repos/globality-corp/microcosm-pubsub","forks_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/forks","keys_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/teams","hooks_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/hooks","issue_events_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/issues/events{/number}","events_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/events","assignees_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/assignees{/user}","branches_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/branches{/branch}","tags_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/tags","blobs_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/git/refs{/sha}","trees_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/statuses/{sha}","languages_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/languages","stargazers_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/stargazers","contributors_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/contributors","subscribers_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/subscribers","subscription_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/subscription","commits_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/commits{/sha}","git_commits_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/git/commits{/sha}","comments_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/comments{/number}","issue_comment_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/issues/comments{/number}","contents_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/contents/{+path}","compare_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/merges","archive_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/downloads","issues_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/issues{/number}","pulls_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls{/number}","milestones_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/milestones{/number}","notifications_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/labels{/name}","releases_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/releases{/id}","deployments_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/deployments","created_at":"2016-03-22T23:37:13Z","updated_at":"2018-07-09T21:05:51Z","pushed_at":"2018-07-26T18:44:59Z","git_url":"git://github.com/globality-corp/microcosm-pubsub.git","ssh_url":"git@github.com:globality-corp/microcosm-pubsub.git","clone_url":"https://github.com/globality-corp/microcosm-pubsub.git","svn_url":"https://github.com/globality-corp/microcosm-pubsub","homepage":null,"size":255,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":5,"open_issues":2,"watchers":1,"default_branch":"develop"}},"base":{"label":"globality-corp:develop","ref":"develop","sha":"eaf33b35e8db059ea3b9f3685ce9fb46edb40e17","user":{"login":"globality-corp","id":11172782,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMTcyNzgy","avatar_url":"https://avatars2.githubusercontent.com/u/11172782?v=4","gravatar_id":"","url":"https://api.github.com/users/globality-corp","html_url":"https://github.com/globality-corp","followers_url":"https://api.github.com/users/globality-corp/followers","following_url":"https://api.github.com/users/globality-corp/following{/other_user}","gists_url":"https://api.github.com/users/globality-corp/gists{/gist_id}","starred_url":"https://api.github.com/users/globality-corp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/globality-corp/subscriptions","organizations_url":"https://api.github.com/users/globality-corp/orgs","repos_url":"https://api.github.com/users/globality-corp/repos","events_url":"https://api.github.com/users/globality-corp/events{/privacy}","received_events_url":"https://api.github.com/users/globality-corp/received_events","type":"Organization","site_admin":false},"repo":{"id":54516201,"node_id":"MDEwOlJlcG9zaXRvcnk1NDUxNjIwMQ==","name":"microcosm-pubsub","full_name":"globality-corp/microcosm-pubsub","owner":{"login":"globality-corp","id":11172782,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMTcyNzgy","avatar_url":"https://avatars2.githubusercontent.com/u/11172782?v=4","gravatar_id":"","url":"https://api.github.com/users/globality-corp","html_url":"https://github.com/globality-corp","followers_url":"https://api.github.com/users/globality-corp/followers","following_url":"https://api.github.com/users/globality-corp/following{/other_user}","gists_url":"https://api.github.com/users/globality-corp/gists{/gist_id}","starred_url":"https://api.github.com/users/globality-corp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/globality-corp/subscriptions","organizations_url":"https://api.github.com/users/globality-corp/orgs","repos_url":"https://api.github.com/users/globality-corp/repos","events_url":"https://api.github.com/users/globality-corp/events{/privacy}","received_events_url":"https://api.github.com/users/globality-corp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/globality-corp/microcosm-pubsub","description":"PubSub with SNS/SQS","fork":false,"url":"https://api.github.com/repos/globality-corp/microcosm-pubsub","forks_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/forks","keys_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/teams","hooks_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/hooks","issue_events_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/issues/events{/number}","events_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/events","assignees_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/assignees{/user}","branches_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/branches{/branch}","tags_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/tags","blobs_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/git/refs{/sha}","trees_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/statuses/{sha}","languages_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/languages","stargazers_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/stargazers","contributors_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/contributors","subscribers_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/subscribers","subscription_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/subscription","commits_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/commits{/sha}","git_commits_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/git/commits{/sha}","comments_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/comments{/number}","issue_comment_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/issues/comments{/number}","contents_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/contents/{+path}","compare_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/merges","archive_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/downloads","issues_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/issues{/number}","pulls_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls{/number}","milestones_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/milestones{/number}","notifications_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/labels{/name}","releases_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/releases{/id}","deployments_url":"https://api.github.com/repos/globality-corp/microcosm-pubsub/deployments","created_at":"2016-03-22T23:37:13Z","updated_at":"2018-07-09T21:05:51Z","pushed_at":"2018-07-26T18:44:59Z","git_url":"git://github.com/globality-corp/microcosm-pubsub.git","ssh_url":"git@github.com:globality-corp/microcosm-pubsub.git","clone_url":"https://github.com/globality-corp/microcosm-pubsub.git","svn_url":"https://github.com/globality-corp/microcosm-pubsub","homepage":null,"size":255,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":5,"open_issues":2,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/88"},"html":{"href":"https://github.com/globality-corp/microcosm-pubsub/pull/88"},"issue":{"href":"https://api.github.com/repos/globality-corp/microcosm-pubsub/issues/88"},"comments":{"href":"https://api.github.com/repos/globality-corp/microcosm-pubsub/issues/88/comments"},"review_comments":{"href":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/88/comments"},"review_comment":{"href":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/globality-corp/microcosm-pubsub/pulls/88/commits"},"statuses":{"href":"https://api.github.com/repos/globality-corp/microcosm-pubsub/statuses/d9e0a5619acc156eab2b333e6ebc0aa2772142ce"}},"author_association":"NONE"}}
{"actor":{"display_login":"jessemyers"}}