英文:
Using Protobuf messages in a Pcollection in Apache Beam using Go causing an error
问题
func processPubSubMsgFn(ctx context.Context, in *pubsub.PubsubMessage) v1.someProto {
someProto := &v1.someProto{}
if err := proto.Unmarshal(in.Data, someProto); err != nil {
log.Fatalln("解析地址簿失败:", err)
}
return *someProto
}
原因:
返回类型错误
由以下原因引起:
编码结构体 v1.someProto
类型具有未导出的字段:state
当尝试运行流水线时,在Java中,我会为消息类型设置编码器,不确定如何在Go版本的Apache Beam中实现这一点。
英文:
func processPubSubMsgFn(ctx context.Context, in *pubsub.PubsubMessage) v1.someProto {
someProto := &v1.someProto{}
if err := proto.Unmarshal((in.Data), someProto); err != nil {
log.Fatalln("Failed to parse address book:", err)
}
return *someProto
}
Causes:
bad return type
caused by:
encoding struct v1.someProto
type has unexported field: state
When trying to run the pipeline, In java I would set the coder for the message type, not sure how to do this in the Go Version of Apache Beam
答案1
得分: 1
根据我在apache beam sdk中的观察,你应该返回*v1.someProto
而不是v1.someProto
。
英文:
From what i see in apache beam sdk you should return *v1.someProto
instead of v1.someProto
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论