[ 
https://issues.apache.org/jira/browse/BEAM-10976?focusedWorklogId=737946&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-737946
 ]

ASF GitHub Bot logged work on BEAM-10976:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Mar/22 04:29
            Start Date: 08/Mar/22 04:29
    Worklog Time Spent: 10m 
      Work Description: youngoli commented on a change in pull request #16980:
URL: https://github.com/apache/beam/pull/16980#discussion_r821310770



##########
File path: sdks/go/pkg/beam/core/runtime/exec/plan.go
##########
@@ -131,6 +141,44 @@ func (p *Plan) Execute(ctx context.Context, id string, 
manager DataContext) erro
        return nil
 }
 
+// Runs any callbacks registered by the bundleFinalizer. Should be run on 
bundle finalization.

Review comment:
       Nit: Godoc comments should start with the name of the function. (See 
https://go.dev/blog/godoc)
   ```suggestion
   // Finalize runs any callbacks registered by the bundleFinalizer. Should be 
run on bundle finalization.
   ```

##########
File path: sdks/go/pkg/beam/core/runtime/exec/plan.go
##########
@@ -131,6 +141,44 @@ func (p *Plan) Execute(ctx context.Context, id string, 
manager DataContext) erro
        return nil
 }
 
+// Runs any callbacks registered by the bundleFinalizer. Should be run on 
bundle finalization.
+func (p *Plan) Finalize() error {
+       if p.status != Up {
+               return errors.Errorf("invalid status for plan %v: %v", p.id, 
p.status)
+       }
+       failedIndices := []int{}
+       for idx, bfc := range p.bf.callbacks {
+               if time.Now().Before(bfc.validUntil) {
+                       if err := bfc.callback(); err != nil {
+                               failedIndices = append(failedIndices, idx)
+                       }
+               }
+       }
+
+       newFinalizer := bundleFinalizer{
+               callbacks:         []bundleFinalizationCallback{},
+               lastValidCallback: time.Now(),
+       }
+
+       for _, idx := range failedIndices {
+               newFinalizer.callbacks = append(newFinalizer.callbacks, 
p.bf.callbacks[idx])
+               if 
newFinalizer.lastValidCallback.Before(p.bf.callbacks[idx].validUntil) {
+                       newFinalizer.lastValidCallback = 
p.bf.callbacks[idx].validUntil
+               }
+       }
+
+       p.bf = &newFinalizer
+
+       if len(failedIndices) > 0 {
+               return errors.Errorf("Plan %v failed %v callbacks", p.ID(), 
len(failedIndices))
+       }
+       return nil
+}
+
+func (p *Plan) GetExpirationTime() time.Time {

Review comment:
       Nit: This function should get a comment too.




-- 
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.

To unsubscribe, e-mail: [email protected]

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 737946)
    Time Spent: 5h 20m  (was: 5h 10m)

> Enable Bundle Finalization in Go SDK
> ------------------------------------
>
>                 Key: BEAM-10976
>                 URL: https://issues.apache.org/jira/browse/BEAM-10976
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-go
>            Reporter: Robert Burke
>            Assignee: Danny McCormick
>            Priority: P3
>          Time Spent: 5h 20m
>  Remaining Estimate: 0h
>
> Eg. to support acking pubsub/kafka messages as processed after the results 
> have been properly committed by the runner.
> Note, that due to BEAM-10959 that when implementing this, an instruction must 
> remain "active" until it's finalization occurs as well. Specifically, we 
> should probably keep another map around for "to be finalized" process bundle 
> instructions so we can return the appropriate "empty" response and not 
> accidently evict them from the nearly equivalent inactive state until after 
> finalization.
> [https://s.apache.org/beam-finalizing-bundles]
>  
> (To be updated once [https://github.com/apache/beam/pull/13160] is merged and 
> the programming guide updated with SDF content.)
> See also Java and Python approaches
> https://beam.apache.org/documentation/programming-guide/#bundle-finalization



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to