Skip to content

Commit 26b0146

Browse files
committed
fix(macro): change marco's enum to same
fix marco Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
1 parent ce3c169 commit 26b0146

File tree

8 files changed

+36
-14
lines changed

8 files changed

+36
-14
lines changed

codegen/src/svcgen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl TtrpcServiceGenerator {
119119
Err(
120120
#mod_path::Error::RpcStatus(
121121
#mod_path::get_status(
122-
#mod_path::Code::NotFound,
122+
#mod_path::Code::NOT_FOUND,
123123
#err_msg,
124124
)
125125
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
pub mod agent_ttrpc;
2+
pub mod health_ttrpc;
3+
pub mod empty;
4+
pub mod types;
5+
// @generated
6+
pub mod streaming;
7+
pub mod agent;
8+
pub mod oci;
9+
pub mod health;
10+
11+
pub mod streaming_ttrpc;
12+
pub mod gogo;

example/protocols/sync/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
pub mod health_ttrpc;
3+
pub mod types;
4+
// @generated
5+
pub mod gogo;
6+
pub mod health;
7+
pub mod agent;
8+
pub mod agent_ttrpc;
9+
pub mod oci;
10+
pub mod empty;

example2/async_server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl health::Health for HealthService {
3333
) -> Result<health::HealthCheckResponse> {
3434
let mut status = Status::default();
3535

36-
status.code = Code::NotFound as i32;
36+
status.code = Code::NOT_FOUND as i32;
3737
status.message = "Just for fun".to_string();
3838

3939
sleep(std::time::Duration::from_secs(10)).await;
@@ -52,7 +52,7 @@ impl health::Health for HealthService {
5252
rep.agent_version = "mock.0.1".to_string();
5353
rep.grpc_version = "0.0.1".to_string();
5454
let mut status = Status::default();
55-
status.code = Code::NotFound as i32;
55+
status.code = Code::NOT_FOUND as i32;
5656
Ok(rep)
5757
}
5858
}

example2/async_stream_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl streaming::Streaming for StreamingService {
122122
for t in tasks {
123123
t.await.unwrap().map_err(|e| {
124124
::ttrpc::Error::RpcStatus(::ttrpc::get_status(
125-
::ttrpc::Code::Unknown,
125+
::ttrpc::Code::UNKNOWN,
126126
e.to_string(),
127127
))
128128
})?;

example2/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl health::Health for HealthService {
3636
_: health::CheckRequest,
3737
) -> Result<health::HealthCheckResponse> {
3838
let mut status = Status::default();
39-
status.code = Code::NotFound as i32;
39+
status.code = Code::NOT_FOUND as i32;
4040
status.message = "Just for fun".to_owned();
4141
Err(Error::RpcStatus(status))
4242
}
@@ -52,7 +52,7 @@ impl health::Health for HealthService {
5252
rep.agent_version = "mock 0.1".to_owned();
5353
rep.grpc_version = "0.0.1".to_owned();
5454
let mut status = Status::default();
55-
status.code = Code::NotFound as i32;
55+
status.code = Code::NOT_FOUND as i32;
5656
Ok(rep)
5757
}
5858
}

src/asynchronous/utils.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ macro_rules! async_request_handler {
6262
let mut res = ::ttrpc::Response::default();
6363
match $class.service.$req_fn(&$ctx, req).await {
6464
Ok(rep) => {
65-
res.status = Some(::ttrpc::get_status(::ttrpc::Code::Ok, "".to_string()));
65+
res.status = Some(::ttrpc::get_status(::ttrpc::Code::OK, "".to_string()));
6666
rep.encode(&mut res.payload)
6767
.map_err(::ttrpc::err_to_others!(e, "Encoding error "))?;
6868
}
@@ -72,7 +72,7 @@ macro_rules! async_request_handler {
7272
}
7373
_ => {
7474
res.status = Some(::ttrpc::get_status(
75-
::ttrpc::Code::Unknown,
75+
::ttrpc::Code::UNKNOWN,
7676
format!("{:?}", x),
7777
));
7878
}
@@ -123,7 +123,7 @@ macro_rules! async_client_streamimg_handler {
123123
let mut res = ::ttrpc::Response::default();
124124
match $class.service.$req_fn(&$ctx, stream).await {
125125
Ok(rep) => {
126-
res.status = Some(::ttrpc::get_status(::ttrpc::Code::Ok, "".to_string()));
126+
res.status = Some(::ttrpc::get_status(::ttrpc::Code::OK, "".to_string()));
127127
rep.encode(&mut res.payload)
128128
.map_err(::ttrpc::err_to_others!(e, "Encoding error "))?;
129129
}
@@ -133,7 +133,7 @@ macro_rules! async_client_streamimg_handler {
133133
}
134134
_ => {
135135
res.status = Some(::ttrpc::get_status(
136-
::ttrpc::Code::Unknown,
136+
::ttrpc::Code::UNKNOWN,
137137
format!("{:?}", x),
138138
));
139139
}
@@ -195,7 +195,7 @@ macro_rules! async_server_streamimg_handler {
195195
}
196196
_ => {
197197
res.status = Some(::ttrpc::get_status(
198-
::ttrpc::Code::Unknown,
198+
::ttrpc::Code::UNKNOWN,
199199
format!("{:?}", x),
200200
));
201201
}
@@ -252,7 +252,7 @@ macro_rules! async_duplex_streamimg_handler {
252252
}
253253
_ => {
254254
res.status = Some(::ttrpc::get_status(
255-
::ttrpc::Code::Unknown,
255+
::ttrpc::Code::UNKNOWN,
256256
format!("{:?}", x),
257257
));
258258
}

src/sync/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ macro_rules! request_handler {
115115
let mut res = ::ttrpc::Response::default();
116116
match $class.service.$req_fn(&$ctx, req) {
117117
Ok(rep) => {
118-
res.status = Some(::ttrpc::get_status(::ttrpc::Code::Ok, "".to_string()));
118+
res.status = Some(::ttrpc::get_status(::ttrpc::Code::OK, "".to_string()));
119119
rep.encode(&mut res.payload)
120120
.map_err(::ttrpc::err_to_others!(e, "Encoding error "))?;
121121
}
@@ -125,7 +125,7 @@ macro_rules! request_handler {
125125
}
126126
_ => {
127127
res.status = Some(::ttrpc::get_status(
128-
::ttrpc::Code::Unknown,
128+
::ttrpc::Code::UNKNOWN,
129129
format!("{:?}", x),
130130
));
131131
}

0 commit comments

Comments
 (0)