我试图实现一个来自互联网的示例,用于 gRPC 与 go 的集成。 https://dzone.com/articles/writing-a-microservice-in-golang-which-communicate
因此,在生成的文件中,没有 RegisterServer 方法,也没有服务内部方法的处理程序。
我的repository-service.proto 文件
package service;
option go_package = "grpc_test/internal/gRPC/service";
import "grpc_test/internal/proto-files/domain/repository.proto";
//RepositoryService Definition
service RepositoryService {
rpc add (domain.Repository) returns (AddRepositoryResponse);
}
message AddRepositoryResponse {
domain.Repository addedRepository = 1;
Error error = 2;
}
message Error {
string code = 1;
string message = 2;
}
Run Code Online (Sandbox Code Playgroud)
生成的.pb.go文件
// source: grpc_test/internal/proto-files/service/repository-service.proto
package service
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
domain "grpc_test/internal/gRPC/domain"
math "math"
)
// Reference imports to suppress errors if they are …
Run Code Online (Sandbox Code Playgroud) 在使用java时我遇到了一个奇怪的情况,让我们先从代码开始.
public static String constructMessage(final String reason, final String xId,
final String yId, final IonStruct metadataStruct) throws DataSanityException {
String message = "";
switch (reason) {
case "NOT_ACTIVE":
if (xId != null) {
message = String.format("Y %s X %s not active: status is inactive%n", yId, xId);
} else {
message = String.format("Y %s not active: status is inactive%n", yId);
}
break;
case "PRICE_GONE":
if (metadataStruct.containsKey("applied")) {
final String applied = metadataStruct.get("applied");
if (applied.equals("single")) {
message = String.format("X %s is not …
Run Code Online (Sandbox Code Playgroud)