jason810496 commented on code in PR #74178:
URL: https://github.com/apache/airflow/pull/74178#discussion_r4181550278


##########
go-sdk/pkg/execution/client.go:
##########
@@ -254,6 +254,24 @@ func (c *CoordinatorClient) PushXCom(
        return err
 }
 
+// deleteXCom asks the supervisor to delete the XCom of ti with the given key. 
Like PushXCom, it
+// leaves map_index out for an unmapped task instance, and the Execution API 
then deletes the XCom
+// with map_index -1.
+func (c *CoordinatorClient) deleteXCom(ctx context.Context, ti 
sdk.TaskInstance, key string) error {
+       msg := genmodels.DeleteXCom{
+               Key:    key,
+               DagID:  ti.DagID,
+               TaskID: ti.TaskID,
+               RunID:  ti.RunID,
+       }
+       if ti.MapIndex != nil && *ti.MapIndex != -1 {
+               msg.MapIndex = ti.MapIndex
+       }

Review Comment:
   nit: this repeats the map_index-omission rule already in `PushXCom`. A 
shared helper keeps a future third caller from copy-pasting a third copy:
   
   ```suggestion
        msg.MapIndex = omittedMapIndex(ti.MapIndex)
   
        _, err := c.comm.Communicate(ctx, msg)
        return err
   }
   
   // omittedMapIndex returns mapIndex, or nil for the unmapped sentinel -1, so 
that msgpack omits
   // map_index from the payload instead of sending it. An explicit index 0 
survives omitempty because
   // the pointer, not the dereferenced int, is returned (see GetXCom).
   func omittedMapIndex(mapIndex *int) *int {
        if mapIndex == nil || *mapIndex == -1 {
                return nil
        }
        return mapIndex
   ```
   
   Worth then switching `PushXCom`'s identical block to the same helper, 
outside this diff.



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

Reply via email to