{"action":"created","comment":{"url":"https://api.github.com/repos/netology-group/http-gateway/pulls/comments/179727427","pull_request_review_id":110021885,"id":179727427,"diff_hunk":"@@ -0,0 +1,97 @@\n+extern crate paho_mqtt as mqtt;\n+\n+use actix::prelude::*;\n+use actix_web::*;\n+\n+use std::time::Duration;\n+\n+pub struct MqttHandler;\n+\n+impl Actor for MqttHandler {\n+    type Context = SyncContext<Self>;\n+}\n+\n+pub struct Params {\n+    pub client_id: String,\n+    pub username: String,\n+    pub password: String,\n+    pub last_will_topic: String,\n+    pub last_will_message: String,\n+    pub request_topic: String,\n+    pub request_qos: u8,\n+    pub response_topic: String,\n+    pub response_qos: u8,\n+}\n+\n+pub struct RPCCall {\n+    pub broker_addr: String,\n+    pub params: Params,\n+    pub payload: Vec<u8>,\n+}\n+\n+impl Message for RPCCall {\n+    type Result = Result<String, mqtt::MqttError>;\n+}\n+\n+impl Handler<RPCCall> for MqttHandler {\n+    type Result = Result<String, mqtt::MqttError>;\n+\n+    fn handle(&mut self, msg: RPCCall, _ctx: &mut Self::Context) -> Self::Result {\n+        let create_opts = mqtt::CreateOptionsBuilder::new()\n+            .server_uri(msg.broker_addr)\n+            .client_id(msg.params.client_id)\n+            .finalize();\n+\n+        let mut cli = mqtt::Client::new(create_opts)?;\n+\n+        let lwt = mqtt::MessageBuilder::new()\n+            .topic(&msg.params.last_will_topic)\n+            .payload(msg.params.last_will_message.as_bytes())\n+            .finalize();\n+\n+        let conn_opts = mqtt::ConnectOptionsBuilder::new()\n+            .keep_alive_interval(Duration::from_secs(20))\n+            .clean_session(true)\n+            .will_message(lwt)\n+            .finalize();\n+\n+        debug!(\"Connecting to the MQTT broker...\");\n+        cli.connect(conn_opts)?;\n+\n+        debug!(\"Subscribing to topics...\");\n+        let rx = cli.start_consuming();\n+\n+        let subscriptions = [&msg.params.response_topic];\n+\n+        cli.subscribe_many(&subscriptions, &[msg.params.response_qos as i32])?;","path":"src/actors/mqtt_handler.rs","position":66,"original_position":66,"commit_id":"fdb11774566168b807e16f947bea2d82f0bdd380","original_commit_id":"fdb11774566168b807e16f947bea2d82f0bdd380","user":{"login":"manifest","id":439058,"avatar_url":"https://avatars1.githubusercontent.com/u/439058?v=4","gravatar_id":"","url":"https://api.github.com/users/manifest","html_url":"https://github.com/manifest","followers_url":"https://api.github.com/users/manifest/followers","following_url":"https://api.github.com/users/manifest/following{/other_user}","gists_url":"https://api.github.com/users/manifest/gists{/gist_id}","starred_url":"https://api.github.com/users/manifest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manifest/subscriptions","organizations_url":"https://api.github.com/users/manifest/orgs","repos_url":"https://api.github.com/users/manifest/repos","events_url":"https://api.github.com/users/manifest/events{/privacy}","received_events_url":"https://api.github.com/users/manifest/received_events","type":"User","site_admin":false},"body":"Why we parse this parameter to string and convert to int it here?","created_at":"2018-04-06T11:16:18Z","updated_at":"2018-04-06T11:17:10Z","html_url":"https://github.com/netology-group/http-gateway/pull/1#discussion_r179727427","pull_request_url":"https://api.github.com/repos/netology-group/http-gateway/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/netology-group/http-gateway/pulls/comments/179727427"},"html":{"href":"https://github.com/netology-group/http-gateway/pull/1#discussion_r179727427"},"pull_request":{"href":"https://api.github.com/repos/netology-group/http-gateway/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/netology-group/http-gateway/pulls/1","id":179786203,"html_url":"https://github.com/netology-group/http-gateway/pull/1","diff_url":"https://github.com/netology-group/http-gateway/pull/1.diff","patch_url":"https://github.com/netology-group/http-gateway/pull/1.patch","issue_url":"https://api.github.com/repos/netology-group/http-gateway/issues/1","number":1,"state":"open","locked":false,"title":"Feature/media 1215","user":{"login":"art-tolpekin","id":36646572,"avatar_url":"https://avatars0.githubusercontent.com/u/36646572?v=4","gravatar_id":"","url":"https://api.github.com/users/art-tolpekin","html_url":"https://github.com/art-tolpekin","followers_url":"https://api.github.com/users/art-tolpekin/followers","following_url":"https://api.github.com/users/art-tolpekin/following{/other_user}","gists_url":"https://api.github.com/users/art-tolpekin/gists{/gist_id}","starred_url":"https://api.github.com/users/art-tolpekin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/art-tolpekin/subscriptions","organizations_url":"https://api.github.com/users/art-tolpekin/orgs","repos_url":"https://api.github.com/users/art-tolpekin/repos","events_url":"https://api.github.com/users/art-tolpekin/events{/privacy}","received_events_url":"https://api.github.com/users/art-tolpekin/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-05T20:22:53Z","updated_at":"2018-04-06T11:17:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"203cd961640c58255b81f240364973422cb6df57","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/netology-group/http-gateway/pulls/1/commits","review_comments_url":"https://api.github.com/repos/netology-group/http-gateway/pulls/1/comments","review_comment_url":"https://api.github.com/repos/netology-group/http-gateway/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netology-group/http-gateway/issues/1/comments","statuses_url":"https://api.github.com/repos/netology-group/http-gateway/statuses/fdb11774566168b807e16f947bea2d82f0bdd380","head":{"label":"netology-group:feature/MEDIA-1215","ref":"feature/MEDIA-1215","sha":"fdb11774566168b807e16f947bea2d82f0bdd380","user":{"login":"netology-group","id":6652293,"avatar_url":"https://avatars0.githubusercontent.com/u/6652293?v=4","gravatar_id":"","url":"https://api.github.com/users/netology-group","html_url":"https://github.com/netology-group","followers_url":"https://api.github.com/users/netology-group/followers","following_url":"https://api.github.com/users/netology-group/following{/other_user}","gists_url":"https://api.github.com/users/netology-group/gists{/gist_id}","starred_url":"https://api.github.com/users/netology-group/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netology-group/subscriptions","organizations_url":"https://api.github.com/users/netology-group/orgs","repos_url":"https://api.github.com/users/netology-group/repos","events_url":"https://api.github.com/users/netology-group/events{/privacy}","received_events_url":"https://api.github.com/users/netology-group/received_events","type":"Organization","site_admin":false},"repo":{"id":125180004,"name":"http-gateway","full_name":"netology-group/http-gateway","owner":{"login":"netology-group","id":6652293,"avatar_url":"https://avatars0.githubusercontent.com/u/6652293?v=4","gravatar_id":"","url":"https://api.github.com/users/netology-group","html_url":"https://github.com/netology-group","followers_url":"https://api.github.com/users/netology-group/followers","following_url":"https://api.github.com/users/netology-group/following{/other_user}","gists_url":"https://api.github.com/users/netology-group/gists{/gist_id}","starred_url":"https://api.github.com/users/netology-group/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netology-group/subscriptions","organizations_url":"https://api.github.com/users/netology-group/orgs","repos_url":"https://api.github.com/users/netology-group/repos","events_url":"https://api.github.com/users/netology-group/events{/privacy}","received_events_url":"https://api.github.com/users/netology-group/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netology-group/http-gateway","description":null,"fork":false,"url":"https://api.github.com/repos/netology-group/http-gateway","forks_url":"https://api.github.com/repos/netology-group/http-gateway/forks","keys_url":"https://api.github.com/repos/netology-group/http-gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netology-group/http-gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netology-group/http-gateway/teams","hooks_url":"https://api.github.com/repos/netology-group/http-gateway/hooks","issue_events_url":"https://api.github.com/repos/netology-group/http-gateway/issues/events{/number}","events_url":"https://api.github.com/repos/netology-group/http-gateway/events","assignees_url":"https://api.github.com/repos/netology-group/http-gateway/assignees{/user}","branches_url":"https://api.github.com/repos/netology-group/http-gateway/branches{/branch}","tags_url":"https://api.github.com/repos/netology-group/http-gateway/tags","blobs_url":"https://api.github.com/repos/netology-group/http-gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netology-group/http-gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netology-group/http-gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/netology-group/http-gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netology-group/http-gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/netology-group/http-gateway/languages","stargazers_url":"https://api.github.com/repos/netology-group/http-gateway/stargazers","contributors_url":"https://api.github.com/repos/netology-group/http-gateway/contributors","subscribers_url":"https://api.github.com/repos/netology-group/http-gateway/subscribers","subscription_url":"https://api.github.com/repos/netology-group/http-gateway/subscription","commits_url":"https://api.github.com/repos/netology-group/http-gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/netology-group/http-gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/netology-group/http-gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/netology-group/http-gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/netology-group/http-gateway/contents/{+path}","compare_url":"https://api.github.com/repos/netology-group/http-gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netology-group/http-gateway/merges","archive_url":"https://api.github.com/repos/netology-group/http-gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netology-group/http-gateway/downloads","issues_url":"https://api.github.com/repos/netology-group/http-gateway/issues{/number}","pulls_url":"https://api.github.com/repos/netology-group/http-gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/netology-group/http-gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/netology-group/http-gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netology-group/http-gateway/labels{/name}","releases_url":"https://api.github.com/repos/netology-group/http-gateway/releases{/id}","deployments_url":"https://api.github.com/repos/netology-group/http-gateway/deployments","created_at":"2018-03-14T08:29:26Z","updated_at":"2018-03-15T17:01:23Z","pushed_at":"2018-04-06T11:14:50Z","git_url":"git://github.com/netology-group/http-gateway.git","ssh_url":"git@github.com:netology-group/http-gateway.git","clone_url":"https://github.com/netology-group/http-gateway.git","svn_url":"https://github.com/netology-group/http-gateway","homepage":null,"size":670,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"netology-group:master","ref":"master","sha":"c5eb0bd19555eb269297d13220501189ffb6ffc4","user":{"login":"netology-group","id":6652293,"avatar_url":"https://avatars0.githubusercontent.com/u/6652293?v=4","gravatar_id":"","url":"https://api.github.com/users/netology-group","html_url":"https://github.com/netology-group","followers_url":"https://api.github.com/users/netology-group/followers","following_url":"https://api.github.com/users/netology-group/following{/other_user}","gists_url":"https://api.github.com/users/netology-group/gists{/gist_id}","starred_url":"https://api.github.com/users/netology-group/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netology-group/subscriptions","organizations_url":"https://api.github.com/users/netology-group/orgs","repos_url":"https://api.github.com/users/netology-group/repos","events_url":"https://api.github.com/users/netology-group/events{/privacy}","received_events_url":"https://api.github.com/users/netology-group/received_events","type":"Organization","site_admin":false},"repo":{"id":125180004,"name":"http-gateway","full_name":"netology-group/http-gateway","owner":{"login":"netology-group","id":6652293,"avatar_url":"https://avatars0.githubusercontent.com/u/6652293?v=4","gravatar_id":"","url":"https://api.github.com/users/netology-group","html_url":"https://github.com/netology-group","followers_url":"https://api.github.com/users/netology-group/followers","following_url":"https://api.github.com/users/netology-group/following{/other_user}","gists_url":"https://api.github.com/users/netology-group/gists{/gist_id}","starred_url":"https://api.github.com/users/netology-group/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netology-group/subscriptions","organizations_url":"https://api.github.com/users/netology-group/orgs","repos_url":"https://api.github.com/users/netology-group/repos","events_url":"https://api.github.com/users/netology-group/events{/privacy}","received_events_url":"https://api.github.com/users/netology-group/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netology-group/http-gateway","description":null,"fork":false,"url":"https://api.github.com/repos/netology-group/http-gateway","forks_url":"https://api.github.com/repos/netology-group/http-gateway/forks","keys_url":"https://api.github.com/repos/netology-group/http-gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netology-group/http-gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netology-group/http-gateway/teams","hooks_url":"https://api.github.com/repos/netology-group/http-gateway/hooks","issue_events_url":"https://api.github.com/repos/netology-group/http-gateway/issues/events{/number}","events_url":"https://api.github.com/repos/netology-group/http-gateway/events","assignees_url":"https://api.github.com/repos/netology-group/http-gateway/assignees{/user}","branches_url":"https://api.github.com/repos/netology-group/http-gateway/branches{/branch}","tags_url":"https://api.github.com/repos/netology-group/http-gateway/tags","blobs_url":"https://api.github.com/repos/netology-group/http-gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netology-group/http-gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netology-group/http-gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/netology-group/http-gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netology-group/http-gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/netology-group/http-gateway/languages","stargazers_url":"https://api.github.com/repos/netology-group/http-gateway/stargazers","contributors_url":"https://api.github.com/repos/netology-group/http-gateway/contributors","subscribers_url":"https://api.github.com/repos/netology-group/http-gateway/subscribers","subscription_url":"https://api.github.com/repos/netology-group/http-gateway/subscription","commits_url":"https://api.github.com/repos/netology-group/http-gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/netology-group/http-gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/netology-group/http-gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/netology-group/http-gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/netology-group/http-gateway/contents/{+path}","compare_url":"https://api.github.com/repos/netology-group/http-gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netology-group/http-gateway/merges","archive_url":"https://api.github.com/repos/netology-group/http-gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netology-group/http-gateway/downloads","issues_url":"https://api.github.com/repos/netology-group/http-gateway/issues{/number}","pulls_url":"https://api.github.com/repos/netology-group/http-gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/netology-group/http-gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/netology-group/http-gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netology-group/http-gateway/labels{/name}","releases_url":"https://api.github.com/repos/netology-group/http-gateway/releases{/id}","deployments_url":"https://api.github.com/repos/netology-group/http-gateway/deployments","created_at":"2018-03-14T08:29:26Z","updated_at":"2018-03-15T17:01:23Z","pushed_at":"2018-04-06T11:14:50Z","git_url":"git://github.com/netology-group/http-gateway.git","ssh_url":"git@github.com:netology-group/http-gateway.git","clone_url":"https://github.com/netology-group/http-gateway.git","svn_url":"https://github.com/netology-group/http-gateway","homepage":null,"size":670,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/netology-group/http-gateway/pulls/1"},"html":{"href":"https://github.com/netology-group/http-gateway/pull/1"},"issue":{"href":"https://api.github.com/repos/netology-group/http-gateway/issues/1"},"comments":{"href":"https://api.github.com/repos/netology-group/http-gateway/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/netology-group/http-gateway/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/netology-group/http-gateway/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netology-group/http-gateway/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/netology-group/http-gateway/statuses/fdb11774566168b807e16f947bea2d82f0bdd380"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"manifest"}}