우리는 proto3를 사용하여 grpc 서버를 만들고 있습니다. 이것을 ActiveRecord-Protobuf gem을 사용하여 protobuf-message ("activerecord".to_proto 메소드를 호출하여 얻음)로 변환했습니다. 그러나 루비 서버를 생성하기 위해 protobuf 메시지를 생성하는 동안 우리는 "activerecord".to_proto 메시지를 전달할 수 없습니다. 입력 값의 유형을 정의하는 동안 우리는 다른 것을 가지고 있지 않지만 proto3에서 메시지로 정의하기 때문에 해시 값만 허용합니다. 우리가 우리의 .to_proto 객체를 "activerecord".to_proto.to_hash로 변환해야하는 inorder. 이것은 쓸데없고 grpc의 최적화를 감소시킵니다. 아이러니하게도 우리는 그 최적 성 때문에 grpc로 이동하고 있습니다. proto3를 사용하여 protobuf 메시지를 정의하는 방법을 제안하여 "activerecord".to_proto 메시지가 proto3 입력 값 정의와 호환되는지 확인하십시오.protobuf 메시지를 정의하여 protomsg를 컴파일하여 활성 레코드 protobuf 메시지를 입력 매개 변수로 직접 루비 GRPC 코드에 전달하는 방법은 무엇입니까?
활성 레코드 개체입니다.
class AppPreferenceMessage < ::Protobuf::Message
optional ::Protobuf::Field::Int64Field, :id, 1
optional ::Protobuf::Field::StringField, :preference_key, 2
optional ::Protobuf::Field::StringField, :value, 3
optional ::Protobuf::Field::StringField, :value_type, 4
optional ::Protobuf::Field::Int64Field, :vaccount_id, 5
end
이는별로 protobuf 메시지입니다 AppPreference.last.to_proto로 변환됩니다.
내 protobuf 정의 루비 입력 매개 변수의 정의는 다음과 같습니다.
syntax="proto3";
service App_Preferences{
rpc Index(Empty) returns (Index_Output){}
}
message Index_Output{
int64 id=1;
string preference_key=2;
string value=3;
string value_type=4;
int64 vaccount_id = 5;
}
이 매개 변수 "Index_Output"은 AppPreference.last.to_proto.to_hash를 수용하지만 난 그것을 입력으로 AppPreference.last.to_proto을 수용하려는 그러나. protobuf 코드를 어떻게 변경합니까?