File tree 3 files changed +7
-5
lines changed
3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ services:
32
32
- 8080:8080
33
33
environment :
34
34
DATABASE_URL : postgres://sakura:password@db:5432/sakura
35
+ MQTT_URL : mqtt://mqtt:1883
35
36
networks :
36
37
- sakura-internal
37
38
- sakura-external
Original file line number Diff line number Diff line change
1
+ use std:: collections:: HashMap ;
2
+ use std:: env;
3
+
1
4
use crate :: domain:: repository:: mqtt:: client:: MqttClientRepository ;
2
5
use crate :: infrastructures:: config:: mqtt_config:: MqttConfig ;
3
6
use crate :: infrastructures:: iot:: mqtt_client:: MqttClient ;
4
7
use crate :: server:: connection:: RequestContext ;
5
8
6
- use std:: collections:: HashMap ;
7
- use std:: env;
8
-
9
9
pub struct MqttConnection {
10
10
cfg : MqttConfig ,
11
11
}
@@ -16,9 +16,10 @@ impl MqttConnection {
16
16
}
17
17
18
18
pub fn mqtt_client_repository ( & self ) -> impl MqttClientRepository {
19
+ let address = env:: var ( "MQTT_URL" ) . expect ( "MQTT_URL is not set" ) ;
19
20
let host = env:: args ( )
20
21
. nth ( 1 )
21
- . unwrap_or_else ( || "mqtt://" . to_string ( ) + & self . cfg . address ) ;
22
+ . unwrap_or_else ( || "mqtt://" . to_string ( ) + & address) ;
22
23
23
24
let create_opts = paho_mqtt:: CreateOptionsBuilder :: new ( )
24
25
. server_uri ( host)
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ pub struct RequestContext {
20
20
impl RequestContext {
21
21
pub fn new ( ) -> RequestContext {
22
22
dotenv ( ) . ok ( ) ;
23
- let db_url = env:: var ( "DATABASE_URL" ) . expect ( "DATABASE_URL i not set" ) ;
23
+ let db_url = env:: var ( "DATABASE_URL" ) . expect ( "DATABASE_URL is not set" ) ;
24
24
let manager = ConnectionManager :: < PgConnection > :: new ( db_url) ;
25
25
let pool = Pool :: builder ( )
26
26
. build ( manager)
You can’t perform that action at this time.
0 commit comments