File tree Expand file tree Collapse file tree 7 files changed +32
-23
lines changed Expand file tree Collapse file tree 7 files changed +32
-23
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ homepage = "https://github.com/alipay/ttrpc-rust"
11
11
description = " An example of ttrpc."
12
12
13
13
[dev-dependencies ]
14
- protobuf = " 2.8 .0"
14
+ protobuf = " 3.1 .0"
15
15
bytes = " 0.4.11"
16
16
libc = " 0.2.79"
17
17
byteorder = " 1.3.2"
Original file line number Diff line number Diff line change @@ -66,17 +66,17 @@ impl agent_ttrpc::AgentService for AgentService {
66
66
_ctx : & :: ttrpc:: r#async:: TtrpcContext ,
67
67
_req : agent:: ListInterfacesRequest ,
68
68
) -> :: ttrpc:: Result < agent:: Interfaces > {
69
- let mut rp = protobuf :: RepeatedField :: new ( ) ;
69
+ let mut rp = Vec :: new ( ) ;
70
70
71
71
let mut i = types:: Interface :: new ( ) ;
72
- i. set_name ( "first" . to_string ( ) ) ;
72
+ i. name = "first" . to_string ( ) ;
73
73
rp. push ( i) ;
74
74
let mut i = types:: Interface :: new ( ) ;
75
- i. set_name ( "second" . to_string ( ) ) ;
75
+ i. name = "second" . to_string ( ) ;
76
76
rp. push ( i) ;
77
77
78
78
let mut i = agent:: Interfaces :: new ( ) ;
79
- i. set_Interfaces ( rp ) ;
79
+ i. Interfaces = rp ;
80
80
81
81
Ok ( i)
82
82
}
Original file line number Diff line number Diff line change 3
3
// SPDX-License-Identifier: Apache-2.0
4
4
//
5
5
6
- use std:: fs:: File ;
7
- use std:: io:: { Read , Write } ;
8
- use ttrpc_codegen:: Codegen ;
9
- use ttrpc_codegen:: Customize ;
6
+ use std:: {
7
+ fs:: File ,
8
+ io:: { Read , Write } ,
9
+ } ;
10
+ use ttrpc_codegen:: { Codegen , Customize , ProtobufCustomize } ;
10
11
11
12
fn main ( ) {
12
13
let mut protos = vec ! [
14
+ "protocols/protos/github.com/gogo/protobuf/gogoproto/gogo.proto" ,
13
15
"protocols/protos/github.com/kata-containers/agent/pkg/types/types.proto" ,
14
16
"protocols/protos/agent.proto" ,
15
17
"protocols/protos/health.proto" ,
16
18
"protocols/protos/google/protobuf/empty.proto" ,
17
19
"protocols/protos/oci.proto" ,
18
20
] ;
19
21
22
+ let protobuf_customized = ProtobufCustomize :: default ( ) . gen_mod_rs ( false ) ;
23
+
20
24
Codegen :: new ( )
21
25
. out_dir ( "protocols/sync" )
22
26
. inputs ( & protos)
@@ -25,6 +29,7 @@ fn main() {
25
29
. customize ( Customize {
26
30
..Default :: default ( )
27
31
} )
32
+ . rust_protobuf_customize ( protobuf_customized. clone ( ) )
28
33
. run ( )
29
34
. expect ( "Gen sync code failed." ) ;
30
35
@@ -40,6 +45,7 @@ fn main() {
40
45
async_all : true ,
41
46
..Default :: default ( )
42
47
} )
48
+ . rust_protobuf_customize ( protobuf_customized. clone ( ) )
43
49
. run ( )
44
50
. expect ( "Gen async code failed." ) ;
45
51
Original file line number Diff line number Diff line change 6
6
pub mod agent;
7
7
pub mod agent_ttrpc;
8
8
pub mod empty;
9
+ mod gogo;
9
10
pub mod health;
10
11
pub mod health_ttrpc;
11
12
mod oci;
12
- pub mod types;
13
13
pub mod streaming;
14
14
pub mod streaming_ttrpc;
15
+ pub mod types;
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ option (gogoproto.benchgen_all) = true;
17
17
18
18
message CheckRequest {
19
19
string service = 1 ;
20
+ optional string option_val = 2 ;
20
21
}
21
22
22
23
message HealthCheckResponse {
Original file line number Diff line number Diff line change 6
6
pub mod agent;
7
7
pub mod agent_ttrpc;
8
8
pub mod empty;
9
+ mod gogo;
9
10
pub mod health;
10
11
pub mod health_ttrpc;
11
12
mod oci;
Original file line number Diff line number Diff line change @@ -63,19 +63,19 @@ impl agent_ttrpc::AgentService for AgentService {
63
63
_ctx : & :: ttrpc:: TtrpcContext ,
64
64
_req : agent:: ListInterfacesRequest ,
65
65
) -> :: ttrpc:: Result < agent:: Interfaces > {
66
- let mut rp = protobuf :: RepeatedField :: new ( ) ;
67
-
68
- let mut i = types:: Interface :: new ( ) ;
69
- i . set_name ( "first" . to_string ( ) ) ;
70
- rp . push ( i ) ;
71
- let mut i = types :: Interface :: new ( ) ;
72
- i . set_name ( "second" . to_string ( ) ) ;
73
- rp . push ( i ) ;
74
-
75
- let mut i = agent :: Interfaces :: new ( ) ;
76
- i . set_Interfaces ( rp ) ;
77
-
78
- Ok ( i )
66
+ Ok ( agent :: Interfaces {
67
+ Interfaces : vec ! [
68
+ types:: Interface {
69
+ name : "first" . to_string( ) ,
70
+ .. Default :: default ( )
71
+ } ,
72
+ types :: Interface {
73
+ name : "second" . to_string ( ) ,
74
+ .. Default :: default ( )
75
+ } ,
76
+ ] ,
77
+ .. Default :: default ( )
78
+ } )
79
79
}
80
80
}
81
81
You can’t perform that action at this time.
0 commit comments