我是 GCP 的新手。我正在尝试使用 protobuf 将 Pub/Sub 服务与架构定义结合使用。
架构:
syntax = "proto3";
import "google/protobuf/any.proto";
message Endorsement {
string endorserId=1;
google.protobuf.Any data = 2;
string signature=3;
bool isVerified=4;
}
message TransactionPayload {
string policyId =1;
string txnId =2;
repeated Endorsement endorsements=3;
}
Run Code Online (Sandbox Code Playgroud)
此架构的验证失败并出现错误
协议缓冲区架构无效。导入“google/protobuf/any.proto”尚未加载。
我需要使用 google.protobuf.Any,还有其他方法可以使用/定义它吗?
我将 grpc v1.34.1 与 Java 结合使用,很难配置客户端负载平衡,因为该版本中不推荐使用某些方法。在早期版本中通过以下方式配置客户端负载平衡非常简单:
final ManagedChannel channel = ManagedChannelBuilder.forTarget(target)
.nameResolverFactory(new DnsNameResolverProvider()) // this is on by default
.loadBalancerFactory(RoundRobinLoadBalancerFactory.getInstance())
.usePlaintext(true)
.build();
Run Code Online (Sandbox Code Playgroud)
或者通过这个https://sultanov.dev/blog/grpc-client-side-load-balancing/
但是,没有任何可用于已弃用nameResolverFactory并删除 method的新版本的参考loadBalancerFactory。
NameResolver.Factory nameResolverFactory = new MultiAddressNameResolverFactory(
new InetSocketAddress("localhost", 50000),
new InetSocketAddress("localhost", 50001),
new InetSocketAddress("localhost", 50002)
);
channel = ManagedChannelBuilder.forTarget("localhost")
.nameResolverFactory(nameResolverFactory)
.defaultLoadBalancingPolicy("round_robin")
.usePlaintext()
.build();
Run Code Online (Sandbox Code Playgroud)
客户端负载平衡有效。但是,较新的 API 已弃用nameResolverFactory.
有人可以指出我nameResolverFactory在新版本中使用不同服务器(主机和端口)进行客户端负载平衡的替代方案吗?
我有各种微服务。我已经使用 JWT 实现了安全性。每个服务通过所有服务共享的密钥验证 JWT 令牌。
是否可以在所有微服务中共享相同的 JWT 签名密钥?
我无法在 API 网关上实现这一点,因为我必须使用某些需要在每个微服务中触发 Spring Security 的库。