Skip to content

Commit 73ce973

Browse files
committed
optimize codes.
1 parent 72ef428 commit 73ce973

File tree

18 files changed

+226
-226
lines changed

18 files changed

+226
-226
lines changed

Cargo.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ license = "Apache-2.0"
77
readme = "README.md"
88
repository = "https://github.com/jjeffcaii/rsocket-rust"
99
homepage = "https://github.com/jjeffcaii/rsocket-rust"
10-
description = """
11-
rsocket-rust is an implementation of the RSocket protocol in Rust.
12-
"""
10+
description = "rsocket-rust is an implementation of the RSocket protocol in Rust."
1311

1412
[dependencies]
13+
log = "0.4.8"
1514
bytes = "0.4.12"
15+
futures = "0.1.28"
1616
tokio = "0.1.22"
17+
18+
[dev-dependencies]
19+
env_logger = "0.6.2"
1720
hex = "0.3.2"
18-
futures = "0.1.28"
21+
22+
[[example]]
23+
name = "echo"
24+
path = "examples/echo/main.rs"

README.md

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# rsocket-rust
2+
23
![logo](./logo.jpg)
34

45
[![Crates.io](https://img.shields.io/crates/v/rsocket_rust)](https://crates.io/crates/rsocket_rust)
56
[![Crates.io](https://img.shields.io/crates/d/rsocket_rust)](https://crates.io/crates/rsocket_rust)
67
[![License](https://img.shields.io/github/license/jjeffcaii/rsocket-rust.svg)](https://github.com/jjeffcaii/rsocket-rust/blob/master/LICENSE)
78
[![GitHub Release](https://img.shields.io/github/release-pre/jjeffcaii/rsocket-rust.svg)](https://github.com/jjeffcaii/rsocket-rust/releases)
89

9-
> rsocket-rust is an implementation of the RSocket protocol in Rust.
10-
<br>It is under active development. Do not use it in a production environment.
10+
> rsocket-rust is an implementation of the RSocket protocol in Rust.
11+
It is under active development. **Do not use it in a production environment!**
1112

1213
## Example
1314

1415
> Here are some example codes which show how RSocket works in Rust. :sunglasses:
1516
1617
### Server
18+
1719
```rust
1820
extern crate bytes;
1921
extern crate futures;
@@ -78,36 +80,38 @@ fn test_client() {
7880
```
7981

8082
## Dependencies
81-
1. [Tokio](https://tokio.rs/)
82-
2. [futures-rs](http://rust-lang-nursery.github.io/futures-rs/)
83+
84+
- [Tokio](https://tokio.rs/)
85+
- [futures-rs](http://rust-lang-nursery.github.io/futures-rs/)
8386

8487
## TODO
85-
- Codec
86-
- [x] Setup
87-
- [x] Keepalive
88-
- [x] Payload
89-
- [x] RequestResponse
90-
- [x] RequestStream
91-
- [x] RequestChannel
92-
- [x] RequestFireAndForget
93-
- [x] MetadataPush
94-
- [x] RequestN
95-
- [x] Resume
96-
- [x] ResumeOK
97-
- [x] Cancel
98-
- [x] Error
99-
- [x] Lease
100-
- Operations
101-
- [x] METADATA_PUSH
102-
- [x] REQUEST_FNF
103-
- [x] REQUEST_RESPONSE
104-
- [x] REQUEST_STREAM
105-
- [ ] REQUEST_CHANNEL
106-
- Transport
107-
- [x] TCP
108-
- [ ] Websocket
109-
- Rx
110-
- [ ] ...
111-
- High Level APIs
112-
- [x] Client
113-
- [x] Server
88+
89+
- Codec
90+
- [x] Setup
91+
- [x] Keepalive
92+
- [x] Payload
93+
- [x] RequestResponse
94+
- [x] RequestStream
95+
- [x] RequestChannel
96+
- [x] RequestFireAndForget
97+
- [x] MetadataPush
98+
- [x] RequestN
99+
- [x] Resume
100+
- [x] ResumeOK
101+
- [x] Cancel
102+
- [x] Error
103+
- [x] Lease
104+
- Operations
105+
- [x] METADATA_PUSH
106+
- [x] REQUEST_FNF
107+
- [x] REQUEST_RESPONSE
108+
- [x] REQUEST_STREAM
109+
- [ ] REQUEST_CHANNEL
110+
- Transport
111+
- [x] TCP
112+
- [ ] Websocket
113+
- Rx
114+
- [ ] ...
115+
- High Level APIs
116+
- [x] Client
117+
- [x] Server

examples/echo/main.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#![allow(unused_variables)]
2+
#![allow(unused_imports)]
3+
#![allow(dead_code)]
4+
5+
#[macro_use]
6+
extern crate log;
7+
extern crate bytes;
8+
extern crate env_logger;
9+
extern crate futures;
10+
extern crate rsocket_rust;
11+
extern crate tokio;
12+
13+
use bytes::Bytes;
14+
use futures::prelude::*;
15+
use rsocket_rust::prelude::*;
16+
17+
fn main() {
18+
env_logger::builder()
19+
.default_format_timestamp_nanos(true)
20+
.init();
21+
22+
let server = RSocketFactory::receive()
23+
.transport(URI::Tcp("127.0.0.1:7878"))
24+
.acceptor(|setup, sending_socket| {
25+
info!("accept setup: {:?}", setup);
26+
// TODO: use tokio runtime?
27+
// std::thread::spawn(move || {
28+
// let resp = sending_socket
29+
// .request_response(
30+
// Payload::builder()
31+
// .set_data(Bytes::from("Hello Client!"))
32+
// .build(),
33+
// )
34+
// .wait()
35+
// .unwrap();
36+
// println!(">>>>> response success: {:?}", resp);
37+
// });
38+
Box::new(MockResponder)
39+
})
40+
.serve();
41+
tokio::run(server);
42+
}

0 commit comments

Comments
 (0)