Skip to content

Commit

Permalink
⚗️ 更新实验代码
Browse files Browse the repository at this point in the history
  • Loading branch information
czy-29 committed Jan 10, 2025
1 parent 81156d0 commit 5d6295a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
8 changes: 6 additions & 2 deletions tracing-surreal/src/bin/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ async fn db() -> AnyRes<Surreal<Client>> {
#[tokio::main]
async fn main() -> AnyRes {
let stop = Stop::init(db().await?, "test").await?;
let mut server = stop.build_server_default().start().await?;
let mut server = stop
.build_server_default()
.pusher_token("fucker")
.start()
.await?;
println!("{}", server.get_local_addr());

let grace_type = match timeout(Duration::from_secs_f64(5.0), &mut server).await {
let grace_type = match timeout(Duration::from_secs_f64(30.0), &mut server).await {
Err(_) => {
println!("5s elapsed, initiating shutdown...");
server.graceful_shutdown().await??
Expand Down
18 changes: 17 additions & 1 deletion tracing-surreal/src/bin/pusher.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
fn main() {
use est::AnyRes;
use std::time::Duration;
use tokio::time::sleep;
use tokio_tungstenite::{connect_async, tungstenite::error};

#[tokio::main]
async fn main() -> AnyRes {
let res = connect_async("ws://127.0.0.1:8192/pusher?111=222&token=fucker&333=444").await;
if let Err(error::Error::Http(resp)) = &res {
println!(
"{}",
String::from_utf8(resp.body().clone().unwrap()).unwrap()
);
}
let (_stream, _resp) = res?;
sleep(Duration::from_secs(10)).await;
println!("Hello, world!");
Ok(())
}

0 comments on commit 5d6295a

Please sign in to comment.