diff --git a/pom.xml b/pom.xml
index 8962d3c..6d0a9f0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,9 +13,12 @@
0.0.1-SNAPSHOT
demo
Demo project for Spring Boot
+
17
+ 1.0.0
+
org.springframework.boot
@@ -38,6 +41,12 @@
2.2.0
+
+ com.tencent.trpc
+ trpc-mini
+ 1.1.0
+
+
org.springframework.boot
spring-boot-starter-test
@@ -51,6 +60,21 @@
org.springframework.boot
spring-boot-maven-plugin
+
+ com.tencent.trpc
+ trpc-maven-plugin
+ ${trpc-maven-plugin.version}
+
+
+
+ gen-code
+
+
+
+
+ true
+
+
diff --git a/src/main/java/io/github/devopsws/demo/service/TRPCService.java b/src/main/java/io/github/devopsws/demo/service/TRPCService.java
new file mode 100644
index 0000000..9d4efd5
--- /dev/null
+++ b/src/main/java/io/github/devopsws/demo/service/TRPCService.java
@@ -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();
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/proto/demo.proto b/src/main/proto/demo.proto
new file mode 100644
index 0000000..b3d3723
--- /dev/null
+++ b/src/main/proto/demo.proto
@@ -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) {}
+}