From 041fd59a960f7a0576d26700484fa6357ae44fac Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Thu, 28 Mar 2024 11:17:11 +0100 Subject: [PATCH] Remove deprecation for task.Wait and task.WaitForResult --- object/task.go | 14 ++++++++++++-- property/wait.go | 4 ---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/object/task.go b/object/task.go index 373407cc4..583bcc6e0 100644 --- a/object/task.go +++ b/object/task.go @@ -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 { @@ -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 { diff --git a/property/wait.go b/property/wait.go index 6b173afed..07ea3cb5d 100644 --- a/property/wait.go +++ b/property/wait.go @@ -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,