diff --git a/sdks/go/examples/snippets/04transforms.go b/sdks/go/examples/snippets/04transforms.go index 31659d2e273a..42a13bd54264 100644 --- a/sdks/go/examples/snippets/04transforms.go +++ b/sdks/go/examples/snippets/04transforms.go @@ -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" @@ -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 { diff --git a/website/www/site/content/en/documentation/programming-guide.md b/website/www/site/content/en/documentation/programming-guide.md index c62ebda98169..d2f06417e8e8 100644 --- a/website/www/site/content/en/documentation/programming-guide.md +++ b/website/www/site/content/en/documentation/programming-guide.md @@ -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}