Skip to main content

2 posts tagged with "grpc"

View All Tags

· One min read

现在grpc基本上用的都是proto3, 官网 style guide

示例如下:

需要重点掌握slice和map的用法以及rpc的定义

syntax = "proto3";

option go_package="./;proto";

service Greeter {
rpc GetConfigFromVPS(Empty) returns (BMKConfig);
rpc SendConfigToVPS(stream BMKConfig) returns (Empty);
}

message BMKConfig {
repeated Brand brands = 1;
map<string,string> file_map = 2;
}

message Brand {
string short_name = 1;
string full_name = 2;
string color = 3;
}

message Empty {
}

Scalar Value Types

A scalar message field can have one of the following types – the table shows the type specified in the .proto file, and the corresponding type in the automatically generated class:

· 2 min read

我在本地的raspberry上部署了nacos,靠ipv6暴露给外面

本地mac和imac访问都是没问题的

但是如果想vps主动给我的raspberry发请求,却不行

ipv6是不支持的,可以用ifconfig看到没有ipv6 address

目前已经反馈给了vps官方

如果官方解决不了,我只能靠grpc的双向流去解决了

思路: client端部署在raspberry pi上,监听nacos配置,如果nacos配置发生变化就把新配置发给vps,然后vps更新内存中的数据

syntax = "proto3";

option go_package="./;proto";

service Greeter {
rpc GetConfigFromVPS(Empty) returns (BMKConfig);
rpc SendConfigToVPS(stream BMKConfig) returns (Empty);
}

message BMKConfig {
repeated Brand brands = 1;
map<string,string> file_map = 2;
}

message Brand {
string short_name = 1;
string full_name = 2;
string color = 3;
}

message Empty {
}

既然vps不能给本地放请求,那么就让本地主动把数据发给vps