File tree 4 files changed +76
-6
lines changed
server/src/main/java/com/hedera/block/server
4 files changed +76
-6
lines changed Original file line number Diff line number Diff line change @@ -45,4 +45,7 @@ gradle-app.setting
45
45
.project
46
46
47
47
# JDT-specific (Eclipse Java Development Tools)
48
- .classpath
48
+ .classpath
49
+
50
+ .idea
51
+ .DS_Store
Original file line number Diff line number Diff line change
1
+ syntax = "proto3" ;
2
+
3
+ option java_package = "com.hedera.block.protos" ;
4
+ option java_outer_classname = "BlockStreamServiceGrpcProto" ;
5
+
6
+ service BlockStreamGrpc {
7
+ rpc GetBlock (BlockRequest ) returns (Block ) {}
8
+ }
9
+
10
+ message Block {
11
+ int64 id = 1 ;
12
+ string value = 2 ;
13
+ }
14
+
15
+ message BlockResponse {
16
+ int64 id = 1 ;
17
+ }
18
+
19
+ message BlockRequest {
20
+ int64 id = 1 ;
21
+ }
Original file line number Diff line number Diff line change
1
+ package com .hedera .block .server ;
2
+
3
+ import com .google .protobuf .Descriptors ;
4
+ import com .hedera .block .protos .BlockStreamServiceGrpcProto ;
5
+ import io .grpc .stub .StreamObserver ;
6
+ import io .helidon .webserver .grpc .GrpcService ;
7
+
8
+ import java .util .logging .Logger ;
9
+
10
+
11
+ public class BlockStreamService implements GrpcService {
12
+
13
+ private final Logger logger = Logger .getLogger (getClass ().getName ());
14
+
15
+ @ Override
16
+ public Descriptors .FileDescriptor proto () {
17
+ return BlockStreamServiceGrpcProto .getDescriptor ();
18
+ }
19
+
20
+ @ Override
21
+ public String serviceName () {
22
+ return "BlockStreamGrpc" ;
23
+ }
24
+
25
+ @ Override
26
+ public void update (Routing routing ) {
27
+ routing .unary ("GetBlock" , this ::getBlock );
28
+ }
29
+
30
+ // @Override void invoke(ReqT request, StreamObserver<RespT> responseObserver);
31
+
32
+ private void getBlock (BlockStreamServiceGrpcProto .BlockRequest request , StreamObserver <BlockStreamServiceGrpcProto .Block > responseObserver ) {
33
+ logger .info ("GetBlock request received" );
34
+ }
35
+
36
+
37
+ }
Original file line number Diff line number Diff line change 1
1
package com .hedera .block .server ;
2
2
3
+ import com .hedera .block .protos .BlockStreamServiceGrpcProto ;
3
4
import com .hedera .block .protos .EchoServiceGrpcProto ;
4
5
import io .grpc .stub .StreamObserver ;
5
6
import io .helidon .webserver .WebServer ;
@@ -24,15 +25,23 @@ public static void main(String[] args) {
24
25
.port (8080 )
25
26
.addRouting (HttpRouting .builder ()
26
27
.get ("/greet" , (req , res ) -> res .send ("Hello World!" )))
28
+ // .addRouting(GrpcRouting.builder()
29
+ // .service(new EchoService())
30
+ // .unary(EchoServiceGrpcProto.getDescriptor(),
31
+ // "EchoService",
32
+ // "Echo",
33
+ // Server::grpcEcho))
27
34
.addRouting (GrpcRouting .builder ()
28
- .service (new EchoService ())
29
- .unary (EchoServiceGrpcProto .getDescriptor (),
30
- "EchoService " ,
31
- "Echo " ,
32
- Server ::grpcEcho ))
35
+ .service (new BlockStreamService ())
36
+ .unary (BlockStreamServiceGrpcProto .getDescriptor (),
37
+ "BlockStreamGrpc " ,
38
+ "GetBlock " ,
39
+ Server ::grpcGetBlock ))
33
40
.build ()
34
41
.start ();
35
42
}
36
43
37
44
static void grpcEcho (EchoServiceGrpcProto .EchoRequest request , StreamObserver <EchoServiceGrpcProto .EchoResponse > responseObserver ) {}
45
+
46
+ static void grpcGetBlock (BlockStreamServiceGrpcProto .BlockRequest request , StreamObserver <BlockStreamServiceGrpcProto .Block > responseObserver ) {}
38
47
}
You can’t perform that action at this time.
0 commit comments