youngoli commented on a change in pull request #14996:
URL: https://github.com/apache/beam/pull/14996#discussion_r651469744



##########
File path: sdks/go/examples/kafka/types/types.go
##########
@@ -0,0 +1,89 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+       "context"
+       "flag"
+       "github.com/apache/beam/sdks/go/pkg/beam/core/graph/window"
+       "github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx"
+       "github.com/apache/beam/sdks/go/pkg/beam/io/kafkaio"
+       log "github.com/apache/beam/sdks/go/pkg/beam/log"
+       "github.com/apache/beam/sdks/go/pkg/beam/x/beamx"
+       "reflect"
+       "time"
+
+       "github.com/apache/beam/sdks/go/pkg/beam"
+)
+
+var (
+       expansionAddr    = flag.String("expansion_addr", "", "Address of 
Expansion Service")
+       bootstrapServers = flag.String("bootstrap_servers", "",
+               "URL of the bootstrap servers for the Kafka cluster. Should be 
accessible by the runner.")
+       topic = flag.String("topic", "kafka_integers_test", "Kafka topic to 
write to and read from.")
+)
+
+func init() {
+       beam.RegisterType(reflect.TypeOf((*LogFn)(nil)).Elem())
+}
+
+// LogFn is a DoFn to log rides.
+type LogFn struct{}
+
+// ProcessElement logs each element it receives.
+func (fn *LogFn) ProcessElement(ctx context.Context, elm []byte) {
+       log.Infof(ctx, "Ride info: %v", string(elm))
+}
+
+// FinishBundle waits a bit so the job server finishes receiving logs.
+func (fn *LogFn) FinishBundle() {
+       time.Sleep(2 * time.Second)
+}
+
+const intSerializer = "org.apache.kafka.common.serialization.IntegerSerializer"
+const intDeserializer = 
"org.apache.kafka.common.serialization.IntegerDeserializer"
+
+func main() {
+       flag.Parse()
+       beam.Init()
+
+       ctx := context.Background()
+       if *expansionAddr == "" {
+               log.Fatal(ctx, "No expansion address provided")
+       }
+
+       p := beam.NewPipeline()
+       s := p.Root()
+
+       elms := make([]interface{}, 100, 100)
+       for i := 1; i <= 100; i++ {
+               elms[i-1] = i
+       }
+       data := beam.Create(s, elms...)
+       kvData := beam.ParDo(s, func(elm int) (int, int) { return 200, elm }, 
data)

Review comment:
       Yeah switching it to int64 seemed to work, although I couldn't get the 
pipeline to ultimately give output. Regardless, I ended up punting this.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to