{"action":"created","issue":{"url":"https://api.github.com/repos/armon/relay/issues/11","repository_url":"https://api.github.com/repos/armon/relay","labels_url":"https://api.github.com/repos/armon/relay/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/armon/relay/issues/11/comments","events_url":"https://api.github.com/repos/armon/relay/issues/11/events","html_url":"https://github.com/armon/relay/pull/11","id":138585154,"number":11,"title":"Make publishers thread-safe","user":{"login":"ryanuber","id":1642288,"avatar_url":"https://avatars.githubusercontent.com/u/1642288?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanuber","html_url":"https://github.com/ryanuber","followers_url":"https://api.github.com/users/ryanuber/followers","following_url":"https://api.github.com/users/ryanuber/following{/other_user}","gists_url":"https://api.github.com/users/ryanuber/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanuber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanuber/subscriptions","organizations_url":"https://api.github.com/users/ryanuber/orgs","repos_url":"https://api.github.com/users/ryanuber/repos","events_url":"https://api.github.com/users/ryanuber/events{/privacy}","received_events_url":"https://api.github.com/users/ryanuber/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-04T21:01:03Z","updated_at":"2016-03-04T23:00:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/armon/relay/pulls/11","html_url":"https://github.com/armon/relay/pull/11","diff_url":"https://github.com/armon/relay/pull/11.diff","patch_url":"https://github.com/armon/relay/pull/11.patch"},"body":"Switches to using a buffer per call to Publish() rather than a global shared one. A `bytes.Buffer` is not thread safe, so if you have a publisher in use in multiple goroutines, it is possible that they will interfere with eachother and write unpredictable messages to the AMQP server.\r\n\r\nThere are two alternative approaches to this:\r\n\r\n1. Document publishers are *not* thread safe. We should probably do that at the broker level even so that the contract is clear.\r\n2. Wrap a mutex around the calls to Publish().\r\n\r\n@armon either way you want to go is fine with me. Let me know what you think."},"comment":{"url":"https://api.github.com/repos/armon/relay/issues/comments/192512309","html_url":"https://github.com/armon/relay/pull/11#issuecomment-192512309","issue_url":"https://api.github.com/repos/armon/relay/issues/11","id":192512309,"user":{"login":"ryanuber","id":1642288,"avatar_url":"https://avatars.githubusercontent.com/u/1642288?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanuber","html_url":"https://github.com/ryanuber","followers_url":"https://api.github.com/users/ryanuber/followers","following_url":"https://api.github.com/users/ryanuber/following{/other_user}","gists_url":"https://api.github.com/users/ryanuber/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanuber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanuber/subscriptions","organizations_url":"https://api.github.com/users/ryanuber/orgs","repos_url":"https://api.github.com/users/ryanuber/repos","events_url":"https://api.github.com/users/ryanuber/events{/privacy}","received_events_url":"https://api.github.com/users/ryanuber/received_events","type":"User","site_admin":false},"created_at":"2016-03-04T23:00:08Z","updated_at":"2016-03-04T23:00:08Z","body":"@armon bringing this in as I think we should probably be thread-safe here for the reasons mentioned above. Let me know if you'd prefer it another way and I can make any adjustments!"}}