【问题标题】:Using Protobuf messages in a Pcollection in Apache Beam using Go causing an error在使用 Go 的 Apache Beam 中的 Pcollection 中使用 Protobuf 消息导致错误
【发布时间】:2021-08-09 01:30:29
【问题描述】:
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
}

原因: 错误的返回类型 造成的: 编码结构 v1.someProto 类型有未导出的字段:状态

在尝试运行管道时,在 java 中我会为消息类型设置编码器,但不确定如何在 Go 版本的 Apache Beam 中执行此操作

【问题讨论】:

  • 我必须将 beam.RegisterType(reflect.TypeOf(v1.someProto{})) 添加到 init() 函数中。

标签: go protocol-buffers apache-beam


【解决方案1】:

根据我在apache beam sdk 中看到的内容,您应该返回*v1.someProto 而不是v1.someProto

【讨论】:

  • 感谢您的帮助,是的,您是正确的。
猜你喜欢
  • 2022-08-19
  • 1970-01-01
  • 2023-02-03
  • 1970-01-01
  • 1970-01-01
  • 2022-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多