-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/io/github/devopsws/demo/service/TRPCService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.github.devopsws.demo.service; | ||
|
||
import com.google.protobuf.TextFormat; | ||
import com.tencent.trpc.core.logger.Logger; | ||
import com.tencent.trpc.core.logger.LoggerFactory; | ||
import com.tencent.trpc.core.rpc.RpcContext; | ||
import io.github.devopsws.trpc.demo.proto.GreeterServiceAPI; | ||
import io.github.devopsws.trpc.demo.proto.HelloRequestProtocol; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class TRPCService implements GreeterServiceAPI { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(TRPCService.class); | ||
|
||
@Override | ||
public HelloRequestProtocol.HelloResponse sayHello(RpcContext context, HelloRequestProtocol.HelloRequest request) { | ||
logger.error(">>>[server]receive msg:{}", TextFormat.shortDebugString(request)); | ||
String message = request.getMessage(); | ||
HelloRequestProtocol.HelloResponse.Builder rspBuilder = HelloRequestProtocol.HelloResponse.newBuilder(); | ||
rspBuilder.setMessage("Hello " + message); | ||
logger.error(">>>[server]return msg:{}", TextFormat.shortDebugString(rspBuilder)); | ||
return rspBuilder.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
syntax = "proto3"; | ||
|
||
package trpc.TestApp.TestServer; | ||
|
||
option java_package = "io.github.devopsws.trpc.demo.proto"; | ||
option java_outer_classname = "HelloRequestProtocol"; | ||
|
||
message HelloRequest { | ||
string message = 1; | ||
} | ||
|
||
message HelloResponse { | ||
string message = 1; | ||
} | ||
|
||
service GreeterService { | ||
rpc sayHello (HelloRequest) returns (HelloResponse) {} | ||
} | ||
|
||
service GreeterService2 { | ||
rpc sayHi (HelloRequest) returns (HelloResponse) {} | ||
} |