kwsc98 opened a new issue, #182:
URL: https://github.com/apache/dubbo-rust/issues/182
### Supports Interface Exposure Mode, make a webServer ? httpClient like
fegin ?
### For Example
### Interface Definition
```rust
#[fusen_trait(package = "org.apache.dubbo.springboot.demo",version =
"1.0.0")]
#[resource(method = POST)]
pub trait DemoService {
#[resource(path="/sayHello11",method = POST)]
async fn sayHello(&self, name: String) -> String;
#[resource(path="/sayHelloV22",method = POST)]
async fn sayHelloV2(&self, name: ReqDto) -> ResDto;
}
```
### Server
```rust
#[derive(Clone)]
struct TestServerImpl {
_db: String,
}
#[fusen_server(version="1.0.0")]
#[resource(path="/TestServer",method = POST)]
impl TestServer for TestServerImpl {
#[resource(path="/doRun1",method = POST)]
async fn do_run1(&self, req1: ReqDto, req2: ReqDto) ->
FusenResult<ResDto> {
info!("req1 : {:?} , req1 : {:?}", req1, req2);
return Ok(ResDto {
str: "Hello ".to_owned() + &req1.str + " " + &req2.str + " V1",
});
}
#[resource(path="/doRun2",method = POST)]
async fn doRun2(&self, req: ReqDto) -> FusenResult<ResDto> {
info!("res : {:?}", req);
return Ok(ResDto {
str: "Hello ".to_owned() + &req.str + " V2",
});
}
}
#[tokio::main(worker_threads = 512)]
async fn main() {
fusen_common::init_log();
let server: TestServerImpl = TestServerImpl {
_db: "我是一个DB数据库".to_string(),
};
FusenServer::build()
.add_register_builder(RegisterBuilder::new(
&format!("127.0.0.1:{}", "2181"),
"default",
RegisterType::ZooKeeper,
))
.add_protocol(Protocol::HTTP("8082".to_owned()))
.add_protocol(Protocol::HTTP2("8081".to_owned()))
.add_fusen_server(Box::new(server))
.run()
.await;
}
```
### Client
```rust
#[tokio::main(worker_threads = 512)]
async fn main() {
let de = TestServerClient::new(&CLI);
println!("{:?}",de.get_info());
fusen_common::init_log();
let client = de;
let res = client
.do_run1(
ReqDto {
str: "client say hello 1".to_string(),
},
ReqDto {
str: "client say hello 2".to_string(),
},
)
.await;
info!("{:?}", res);
let res = client
.doRun2(ReqDto {
str: "client say hello 2".to_string(),
})
.await;
info!("{:?}", res);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]