Skip to content

Commit

Permalink
Remove deprecation for task.Wait and task.WaitForResult
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini authored and dougm committed Apr 2, 2024
1 parent f2a87d7 commit 47c5ff9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 12 additions & 2 deletions object/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ func NewTask(c *vim25.Client, ref types.ManagedObjectReference) *Task {
return &t
}

// Deprecated: Please use WaitEx instead.
// Wait waits for a task to complete.
// NOTE: This method create a thread-safe PropertyCollector instance per-call, so it is thread safe.
// The downside of this approach is the additional resource usage on the vCenter side for each call.
func (t *Task) Wait(ctx context.Context) error {
_, err := t.WaitForResult(ctx, nil)
return err
}

// Deprecated: Please use WaitForResultEx instead.
// WaitForResult wait for a task to complete.
// NOTE: This method create a thread-safe PropertyCollector instance per-call, so it is thread safe.
// The downside of this approach is the additional resource usage on the vCenter side for each call.
func (t *Task) WaitForResult(ctx context.Context, s ...progress.Sinker) (taskInfo *types.TaskInfo, result error) {
var pr progress.Sinker
if len(s) == 1 {
Expand Down Expand Up @@ -79,11 +83,17 @@ func (t *Task) WaitForResult(ctx context.Context, s ...progress.Sinker) (taskInf
return task.WaitEx(ctx, t.Reference(), p, pr)
}

// WaitEx waits for a task to complete.
// NOTE: This method use the same PropertyCollector instance in each call, thus reducing resource usage on the vCenter side.
// The downside of this approach is that this method is not thread safe.
func (t *Task) WaitEx(ctx context.Context) error {
_, err := t.WaitForResultEx(ctx, nil)
return err
}

// WaitForResultEx waits for a task to complete.
// NOTE: This method use the same PropertyCollector instance in each call, thus reducing resource usage on the vCenter side.
// The downside of this approach is that this method is not thread safe.
func (t *Task) WaitForResultEx(ctx context.Context, s ...progress.Sinker) (*types.TaskInfo, error) {
var pr progress.Sinker
if len(s) == 1 {
Expand Down
4 changes: 0 additions & 4 deletions property/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ func Wait(ctx context.Context, c *Collector, obj types.ManagedObjectReference, p
// By default, ObjectUpdate.MissingSet faults are not propagated to the returned
// error, set WaitFilter.PropagateMissing=true to enable MissingSet fault
// propagation.
//
// Deprecated: Please consider using WaitForUpdatesEx instead, as it does not
// create a new property collector, instead it destroys the property filter
// after the expected update is received.
func WaitForUpdates(
ctx context.Context,
c *Collector,
Expand Down

0 comments on commit 47c5ff9

Please sign in to comment.