@@ -5,80 +5,29 @@ extern crate log;
5
5
6
6
7
7
use std:: collections:: HashMap ;
8
- use std:: str:: Utf8Error ;
9
8
use std:: sync:: Arc ;
10
9
use std:: sync:: Mutex ;
11
10
12
- use anyhow:: Context as AnyhowContext ;
13
- use futures:: SinkExt ;
14
- use tokio:: stream:: StreamExt ;
15
- use tokio:: time:: { delay_for, Duration } ;
16
- use warp:: Filter ;
11
+ use warp:: { Filter } ;
17
12
use warp:: hyper:: Method ;
18
- use libzmq:: { prelude:: * , * } ;
19
13
20
14
use aws:: ecs:: get_ecs_filter;
21
- use error:: handle_rejection;
22
15
23
16
use crate :: aws:: cloudwatch_logs:: { get_logs_events_filter, get_logs_filter} ;
24
17
use crate :: aws:: cloudwatch_logs:: dto:: LogsOptions ;
25
18
use crate :: aws:: dto:: AwsRequest ;
26
19
use crate :: aws:: manager:: setup_default_manager;
27
- use crate :: notifications:: { build_fan_notifications, NotUtf8 , subscriber_connected} ;
28
- use libzmq:: InprocAddr ;
29
- use std:: thread;
20
+ use error:: handle_rejection;
21
+ use crate :: notifications:: { subscriber_connected, build_fan_notifications, NotUtf8 } ;
30
22
31
- mod test;
32
23
mod aws;
33
24
mod error;
34
25
mod notifications;
35
26
36
27
#[ tokio:: main]
37
- async fn main ( ) -> Result < ( ) , anyhow :: Error > {
28
+ async fn main ( ) {
38
29
pretty_env_logger:: init ( ) ;
39
30
40
- let inproc_addr: InprocAddr = InprocAddr :: new_unique ( ) ;
41
- let inproc_socket = ServerBuilder :: new ( ) . bind ( & inproc_addr) . build ( ) ?;
42
- let subscriber_addr: TcpAddr = "eth0;192.168.1.1:5555" . try_into ( ) ?;
43
- let publish_socket = ClientBuilder :: new ( ) . connect ( subscriber_addr) . build ( ) ?;
44
-
45
- // Spawn the server thread.
46
- let handle = thread:: spawn ( move || -> Result < ( ) , Error > {
47
- loop {
48
- let request = inproc_socket. recv_msg ( ) ?;
49
- let msg = request. to_str ( ) . unwrap_or_default ( ) ;
50
- info ! ( "Received a message on the inproc socket, msg: {}" , msg) ;
51
- publish_socket. send ( msg) . unwrap_or_default ( ) ;
52
- }
53
- } ) ;
54
-
55
- let client = ClientBuilder :: new ( ) . connect ( inproc_addr) . build ( ) ?;
56
-
57
-
58
-
59
- // let publish_notification = context.socket(zmq::PUB)
60
- // .with_context(|| "Failed to instantiate notification socket!").unwrap();
61
- // publish_notification
62
- // .bind("tcp://127.0.0.1:3031").unwrap();
63
- //
64
- // let inproc_socket = context.socket(zmq::SUB)
65
- // .with_context(|| "Failed to instantiate inproc socket!").unwrap();
66
- // inproc_socket
67
- // .connect("inproc://internal_proxy").unwrap();
68
- // inproc_socket
69
- // .set_subscribe(b"")
70
- // .expect("failed setting subscription");
71
- //
72
- // std::thread::spawn(move || {
73
- // while let Ok(msg) = inproc_socket.recv_msg(0) {
74
- // info!("Received a message on the inproc socket");
75
- // let result = publish_notification.send(msg, 0);
76
- // if let Err(err) = result {
77
- // error!("Error sending message to notification sender!, err {}", err)
78
- // }
79
- // }
80
- // });
81
-
82
31
83
32
let subscribers = Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ;
84
33
let subscribers = warp:: any ( ) . map ( move || subscribers. clone ( ) ) ;
@@ -138,12 +87,6 @@ async fn main() -> Result<(), anyhow::Error> {
138
87
warp:: reply ( )
139
88
} ) ;
140
89
141
- let socket_test = warp:: path ( "sockettest" )
142
- . and ( warp:: post ( ) )
143
- . and ( warp:: body:: content_length_limit ( 500 ) )
144
- . and ( warp:: body:: bytes ( ) )
145
- . and_then ( move r|msg| notifications:: handle_message ( msg, client. clone ( ) ) ) ;
146
-
147
90
let notifications = warp:: path ( "notifications" )
148
91
. and ( warp:: get ( ) )
149
92
. and ( subscribers)
@@ -158,19 +101,9 @@ async fn main() -> Result<(), anyhow::Error> {
158
101
. or ( log_stream)
159
102
. or ( bootstrap_config)
160
103
. or ( notify)
161
- . or ( socket_test)
162
104
. or ( notifications)
163
105
. with ( cors)
164
106
. recover ( handle_rejection)
165
107
)
166
108
. run ( ( [ 127 , 0 , 0 , 1 ] , 3030 ) ) . await ;
167
-
168
- // This will cause the server to fail with `InvalidCtx`.
169
- Ctx :: global ( ) . shutdown ( ) ;
170
-
171
- // Join with the thread.
172
- let err = handle. join ( ) . unwrap ( ) . unwrap_err ( ) ;
173
- assert_eq ! ( err. kind( ) , ErrorKind :: InvalidCtx ) ;
174
-
175
- Ok ( ( ) )
176
109
}
0 commit comments