Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BEAM-10976] Document go sdk bundle finalization #17048

Merged
merged 4 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions sdks/go/examples/snippets/04transforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"reflect"
"sort"
"strings"
"time"

"github.com/apache/beam/sdks/v2/go/pkg/beam"
"github.com/apache/beam/sdks/v2/go/pkg/beam/core/typex"
Expand Down Expand Up @@ -88,6 +89,22 @@ func CreateAndSplit(s beam.Scope, input []stringPair) beam.PCollection {

// [END cogroupbykey_input_helpers]

type splittableDoFn struct{}

// [START bundlefinalization_simplecallback]

func (fn *splittableDoFn) ProcessElement(element string, bf beam.BundleFinalization) {
// ... produce output ...

bf.RegisterCallback(5*time.Minute, func() error {
// ... perform a side effect ...

return nil
})
}

// [END bundlefinalization_simplecallback]

// [START cogroupbykey_output_helpers]

func formatCoGBKResults(key string, emailIter, phoneIter func(*string) bool) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6535,7 +6535,7 @@ use case.
{{< /highlight >}}

{{< highlight go >}}
This is not supported yet, see BEAM-10976.
{{< code_sample "sdks/go/examples/snippets/04transforms.go" bundlefinalization_simplecallback >}}
{{< /highlight >}}

## 13. Multi-language pipelines {#multi-language-pipelines}
Expand Down