{"action":"created","comment":{"url":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/comments/48688226","id":48688226,"diff_hunk":"@@ -249,6 +249,24 @@ socket = assign(socket, :user, msg[\"user\"])\n \n Sockets store assigned values as a map in `socket.assigns`.\n \n+#### Failure Semantics\n+\n+Servers will restart & clients will fail - understanding how Phoenix responds to these events and the guarantees it offers will  help you design robust systems. \n+\n+- Subscriptions\n+ \n+On the server, subscriptions are held in an ETS table (which resides in memory). If a server restarts or crashes, the subscriptions will need to be recreated for clients to receive updaes. Fortunately, this functionality is built into the Phoenix javascript client. The clients will attempt to reconnect to the server. Once they do, they'll rejoin the channels they were subscribed to using exponential back off.\n+\n+- Channel Crashes\n+\n+If a channel crashes on the server, the client is notified and the `channel.onError` callback is invoked. The client then rejoins using exponential back off.\n+\n+- Messages\n+\n+On the client, messages are queued into a `PushBuffer` and sent to the server when there is a connection. If there isn't a connection available, they'll be held in memory until a connection is established.  The messages are not persisted in LocalStorage or IndexedDb, so if the client's browser tab closes before the messages are sent, the messages are lost.","path":"G_channels.md","position":18,"original_position":18,"commit_id":"839342f492bd8592f3560d265dad98f7ec245b0c","original_commit_id":"839342f492bd8592f3560d265dad98f7ec245b0c","user":{"login":"chrismccord","id":576796,"avatar_url":"https://avatars.githubusercontent.com/u/576796?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismccord","html_url":"https://github.com/chrismccord","followers_url":"https://api.github.com/users/chrismccord/followers","following_url":"https://api.github.com/users/chrismccord/following{/other_user}","gists_url":"https://api.github.com/users/chrismccord/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismccord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismccord/subscriptions","organizations_url":"https://api.github.com/users/chrismccord/orgs","repos_url":"https://api.github.com/users/chrismccord/repos","events_url":"https://api.github.com/users/chrismccord/events{/privacy}","received_events_url":"https://api.github.com/users/chrismccord/received_events","type":"User","site_admin":false},"body":"\"they'll be held in memory until a connection is established, or until they receive a \"timeout\" event, which defaults to 5s.\"","created_at":"2016-01-02T22:28:53Z","updated_at":"2016-01-02T22:28:53Z","html_url":"https://github.com/phoenixframework/phoenix_guides/pull/440#discussion_r48688226","pull_request_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/440","_links":{"self":{"href":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/comments/48688226"},"html":{"href":"https://github.com/phoenixframework/phoenix_guides/pull/440#discussion_r48688226"},"pull_request":{"href":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/440"}}},"pull_request":{"url":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/440","id":53334186,"html_url":"https://github.com/phoenixframework/phoenix_guides/pull/440","diff_url":"https://github.com/phoenixframework/phoenix_guides/pull/440.diff","patch_url":"https://github.com/phoenixframework/phoenix_guides/pull/440.patch","issue_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/issues/440","number":440,"state":"open","locked":false,"title":"Add failure semantics section to Channel guide","user":{"login":"scottmessinger","id":100121,"avatar_url":"https://avatars.githubusercontent.com/u/100121?v=3","gravatar_id":"","url":"https://api.github.com/users/scottmessinger","html_url":"https://github.com/scottmessinger","followers_url":"https://api.github.com/users/scottmessinger/followers","following_url":"https://api.github.com/users/scottmessinger/following{/other_user}","gists_url":"https://api.github.com/users/scottmessinger/gists{/gist_id}","starred_url":"https://api.github.com/users/scottmessinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottmessinger/subscriptions","organizations_url":"https://api.github.com/users/scottmessinger/orgs","repos_url":"https://api.github.com/users/scottmessinger/repos","events_url":"https://api.github.com/users/scottmessinger/events{/privacy}","received_events_url":"https://api.github.com/users/scottmessinger/received_events","type":"User","site_admin":false},"body":"Why?\r\n- It's important to understand failure semantics when deploying a distributed system. The guides don't currently have any documentation on these semantics. \r\n\r\nThis change addresses the need by:\r\n- Describing the failure semantics for subscriptions, channel crashes, and messages.","created_at":"2015-12-10T23:37:16Z","updated_at":"2016-01-02T22:28:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0c89c2959c546fec70417e36cf56d105defbe87","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/440/commits","review_comments_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/440/comments","review_comment_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/comments{/number}","comments_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/issues/440/comments","statuses_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/statuses/839342f492bd8592f3560d265dad98f7ec245b0c","head":{"label":"scottmessinger:patch-1","ref":"patch-1","sha":"839342f492bd8592f3560d265dad98f7ec245b0c","user":{"login":"scottmessinger","id":100121,"avatar_url":"https://avatars.githubusercontent.com/u/100121?v=3","gravatar_id":"","url":"https://api.github.com/users/scottmessinger","html_url":"https://github.com/scottmessinger","followers_url":"https://api.github.com/users/scottmessinger/followers","following_url":"https://api.github.com/users/scottmessinger/following{/other_user}","gists_url":"https://api.github.com/users/scottmessinger/gists{/gist_id}","starred_url":"https://api.github.com/users/scottmessinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottmessinger/subscriptions","organizations_url":"https://api.github.com/users/scottmessinger/orgs","repos_url":"https://api.github.com/users/scottmessinger/repos","events_url":"https://api.github.com/users/scottmessinger/events{/privacy}","received_events_url":"https://api.github.com/users/scottmessinger/received_events","type":"User","site_admin":false},"repo":{"id":47793027,"name":"phoenix_guides","full_name":"scottmessinger/phoenix_guides","owner":{"login":"scottmessinger","id":100121,"avatar_url":"https://avatars.githubusercontent.com/u/100121?v=3","gravatar_id":"","url":"https://api.github.com/users/scottmessinger","html_url":"https://github.com/scottmessinger","followers_url":"https://api.github.com/users/scottmessinger/followers","following_url":"https://api.github.com/users/scottmessinger/following{/other_user}","gists_url":"https://api.github.com/users/scottmessinger/gists{/gist_id}","starred_url":"https://api.github.com/users/scottmessinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottmessinger/subscriptions","organizations_url":"https://api.github.com/users/scottmessinger/orgs","repos_url":"https://api.github.com/users/scottmessinger/repos","events_url":"https://api.github.com/users/scottmessinger/events{/privacy}","received_events_url":"https://api.github.com/users/scottmessinger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/scottmessinger/phoenix_guides","description":"User guides for the Phoenix web development framework.","fork":true,"url":"https://api.github.com/repos/scottmessinger/phoenix_guides","forks_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/forks","keys_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/teams","hooks_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/hooks","issue_events_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/issues/events{/number}","events_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/events","assignees_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/assignees{/user}","branches_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/branches{/branch}","tags_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/tags","blobs_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/git/refs{/sha}","trees_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/statuses/{sha}","languages_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/languages","stargazers_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/stargazers","contributors_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/contributors","subscribers_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/subscribers","subscription_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/subscription","commits_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/commits{/sha}","git_commits_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/git/commits{/sha}","comments_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/comments{/number}","issue_comment_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/issues/comments{/number}","contents_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/contents/{+path}","compare_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/merges","archive_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/downloads","issues_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/issues{/number}","pulls_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/pulls{/number}","milestones_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/milestones{/number}","notifications_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/labels{/name}","releases_url":"https://api.github.com/repos/scottmessinger/phoenix_guides/releases{/id}","created_at":"2015-12-10T23:16:04Z","updated_at":"2015-12-10T23:16:05Z","pushed_at":"2015-12-10T23:37:04Z","git_url":"git://github.com/scottmessinger/phoenix_guides.git","ssh_url":"git@github.com:scottmessinger/phoenix_guides.git","clone_url":"https://github.com/scottmessinger/phoenix_guides.git","svn_url":"https://github.com/scottmessinger/phoenix_guides","homepage":null,"size":1610,"stargazers_count":0,"watchers_count":0,"language":"CSS","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":"phoenixframework:master","ref":"master","sha":"7df514a6d135fbfa4a4e634834b99d327c2f8e80","user":{"login":"phoenixframework","id":6510388,"avatar_url":"https://avatars.githubusercontent.com/u/6510388?v=3","gravatar_id":"","url":"https://api.github.com/users/phoenixframework","html_url":"https://github.com/phoenixframework","followers_url":"https://api.github.com/users/phoenixframework/followers","following_url":"https://api.github.com/users/phoenixframework/following{/other_user}","gists_url":"https://api.github.com/users/phoenixframework/gists{/gist_id}","starred_url":"https://api.github.com/users/phoenixframework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phoenixframework/subscriptions","organizations_url":"https://api.github.com/users/phoenixframework/orgs","repos_url":"https://api.github.com/users/phoenixframework/repos","events_url":"https://api.github.com/users/phoenixframework/events{/privacy}","received_events_url":"https://api.github.com/users/phoenixframework/received_events","type":"Organization","site_admin":false},"repo":{"id":22436876,"name":"phoenix_guides","full_name":"phoenixframework/phoenix_guides","owner":{"login":"phoenixframework","id":6510388,"avatar_url":"https://avatars.githubusercontent.com/u/6510388?v=3","gravatar_id":"","url":"https://api.github.com/users/phoenixframework","html_url":"https://github.com/phoenixframework","followers_url":"https://api.github.com/users/phoenixframework/followers","following_url":"https://api.github.com/users/phoenixframework/following{/other_user}","gists_url":"https://api.github.com/users/phoenixframework/gists{/gist_id}","starred_url":"https://api.github.com/users/phoenixframework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phoenixframework/subscriptions","organizations_url":"https://api.github.com/users/phoenixframework/orgs","repos_url":"https://api.github.com/users/phoenixframework/repos","events_url":"https://api.github.com/users/phoenixframework/events{/privacy}","received_events_url":"https://api.github.com/users/phoenixframework/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/phoenixframework/phoenix_guides","description":"User guides for the Phoenix web development framework.","fork":false,"url":"https://api.github.com/repos/phoenixframework/phoenix_guides","forks_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/forks","keys_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/teams","hooks_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/hooks","issue_events_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/issues/events{/number}","events_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/events","assignees_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/assignees{/user}","branches_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/branches{/branch}","tags_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/tags","blobs_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/git/refs{/sha}","trees_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/statuses/{sha}","languages_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/languages","stargazers_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/stargazers","contributors_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/contributors","subscribers_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/subscribers","subscription_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/subscription","commits_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/commits{/sha}","git_commits_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/git/commits{/sha}","comments_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/comments{/number}","issue_comment_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/issues/comments{/number}","contents_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/contents/{+path}","compare_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/merges","archive_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/downloads","issues_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/issues{/number}","pulls_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls{/number}","milestones_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/milestones{/number}","notifications_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/labels{/name}","releases_url":"https://api.github.com/repos/phoenixframework/phoenix_guides/releases{/id}","created_at":"2014-07-30T17:00:36Z","updated_at":"2016-01-02T18:53:20Z","pushed_at":"2016-01-02T20:04:51Z","git_url":"git://github.com/phoenixframework/phoenix_guides.git","ssh_url":"git@github.com:phoenixframework/phoenix_guides.git","clone_url":"https://github.com/phoenixframework/phoenix_guides.git","svn_url":"https://github.com/phoenixframework/phoenix_guides","homepage":null,"size":1743,"stargazers_count":281,"watchers_count":281,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":135,"mirror_url":null,"open_issues_count":31,"forks":135,"open_issues":31,"watchers":281,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/440"},"html":{"href":"https://github.com/phoenixframework/phoenix_guides/pull/440"},"issue":{"href":"https://api.github.com/repos/phoenixframework/phoenix_guides/issues/440"},"comments":{"href":"https://api.github.com/repos/phoenixframework/phoenix_guides/issues/440/comments"},"review_comments":{"href":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/440/comments"},"review_comment":{"href":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/phoenixframework/phoenix_guides/pulls/440/commits"},"statuses":{"href":"https://api.github.com/repos/phoenixframework/phoenix_guides/statuses/839342f492bd8592f3560d265dad98f7ec245b0c"}}}}