blob: 5245f9a59de2bc8e5a8f3079750bda85ecb62a6e [file] [log] [blame]
// Copyright 2022 Google LLC
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
//> or the MIT license
// <LICENSE-MIT or>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
package main
import (
beamLog ""
var (
input_text = flag.String("input-text", "default input text", "Input text to print.")
func init() {
// DoFns should be registered with Beam to be available in distributed runners.
// You can also access the Context and "emit" zero or more values like FlatMap.
func logAndEmit(ctx context.Context, element string, emit func(string)) {
beamLog.Infoln(ctx, element)
func myPipeline(scope beam.Scope, input_text string) beam.PCollection {
elements := beam.Create(scope, "hello", "world!", input_text)
elements = beam.ParDo(scope, strings.Title, elements)
return beam.ParDo(scope, logAndEmit, elements)
func main() {
ctx := context.Background()
pipeline, scope := beam.NewPipelineWithRoot()
myPipeline(scope, *input_text)
// Run the pipeline. You can specify your runner with the --runner flag.
if err := beamx.Run(ctx, pipeline); err != nil {
log.Fatalf("Failed to execute job: %v", err)