-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from rsocket/feature/async_await
Feature/async await
- Loading branch information
Showing
47 changed files
with
1,331 additions
and
1,158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "rsocket_rust" | ||
version = "0.1.5" | ||
version = "0.2.0" | ||
authors = ["Jeffsky <[email protected]>"] | ||
edition = "2018" | ||
license = "Apache-2.0" | ||
|
@@ -10,19 +10,32 @@ homepage = "https://github.com/rsocket/rsocket-rust" | |
description = "rsocket-rust is an implementation of the RSocket protocol in Rust." | ||
|
||
[dependencies] | ||
matches = "0.1.8" | ||
log = "0.4.8" | ||
bytes = "0.4.12" | ||
futures = "0.1.29" | ||
tokio = "0.1.22" | ||
bytes = "0.5.2" | ||
futures = "0.3.1" | ||
lazy_static = "1.4.0" | ||
# reactor_rs = {git = "https://github.com/jjeffcaii/reactor-rust", branch = "develop"} | ||
|
||
[dependencies.tokio] | ||
version = "0.2.1" | ||
default-features = false | ||
features = ["full"] | ||
|
||
[dependencies.tokio-util] | ||
version = "0.2.0" | ||
default-features = false | ||
features = ["codec"] | ||
|
||
[dev-dependencies] | ||
env_logger = "0.6.2" | ||
hex = "0.3.2" | ||
env_logger = "0.7.1" | ||
hex = "0.4.0" | ||
rand = "0.7.2" | ||
|
||
[[example]] | ||
name = "echo" | ||
path = "examples/echo/main.rs" | ||
|
||
[[example]] | ||
name = "proxy" | ||
path = "examples/proxy/main.rs" | ||
# [[example]] | ||
# name = "proxy" | ||
# path = "examples/proxy/main.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,22 @@ | ||
#![allow(unused_variables)] | ||
#![allow(unused_imports)] | ||
#![allow(dead_code)] | ||
|
||
#[macro_use] | ||
extern crate log; | ||
extern crate bytes; | ||
extern crate env_logger; | ||
extern crate futures; | ||
extern crate rsocket_rust; | ||
extern crate tokio; | ||
|
||
use bytes::Bytes; | ||
use futures::prelude::*; | ||
#[macro_use] | ||
extern crate log; | ||
use rsocket_rust::prelude::*; | ||
use std::env; | ||
use std::error::Error; | ||
|
||
fn main() { | ||
env_logger::builder() | ||
.default_format_timestamp_nanos(true) | ||
.init(); | ||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
env_logger::builder().init(); | ||
let addr = env::args().nth(1).unwrap_or("127.0.0.1:7878".to_string()); | ||
|
||
let server = RSocketFactory::receive() | ||
.transport(URI::Tcp("127.0.0.1:7878")) | ||
.acceptor(|setup, sending_socket| { | ||
info!("accept setup: {:?}", setup); | ||
// TODO: use tokio runtime? | ||
// std::thread::spawn(move || { | ||
// let resp = sending_socket | ||
// .request_response( | ||
// Payload::builder() | ||
// .set_data(Bytes::from("Hello Client!")) | ||
// .build(), | ||
// ) | ||
// .wait() | ||
// .unwrap(); | ||
// println!(">>>>> response success: {:?}", resp); | ||
// }); | ||
Box::new(MockResponder) | ||
}) | ||
.serve(); | ||
tokio::run(server); | ||
RSocketFactory::receive() | ||
.transport(URI::Tcp(addr)) | ||
.acceptor(|setup, _socket| { | ||
info!("accept setup: {:?}", setup); | ||
Box::new(EchoRSocket) | ||
}) | ||
.serve() | ||
.await | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.