GcpCompute.Operations (GcpCompute v0.2.0)

Copy Markdown View Source

Track Compute Engine operations to completion.

Mutating calls return an GcpCompute.Operation immediately; use these functions to wait for the underlying work (boot, delete, …) to finish.

{:ok, op} = GcpCompute.Instances.insert(config, spec)
{:ok, done} = GcpCompute.Operations.poll_until_done(config, op)

Summary

Functions

Fetch the current state of an operation (single GET, no waiting).

Repeatedly wait/2 until the operation is done or :timeout (ms) elapses.

Long-poll an operation once.

Functions

get(config, operation)

Fetch the current state of an operation (single GET, no waiting).

poll_until_done(config, operation, opts \\ [])

@spec poll_until_done(GcpCompute.Config.t(), GcpCompute.Operation.t(), keyword()) ::
  {:ok, GcpCompute.Operation.t()} | {:error, GcpCompute.Error.t()}

Repeatedly wait/2 until the operation is done or :timeout (ms) elapses.

Returns {:ok, done_operation} on success. If the operation completes with an error payload, returns {:error, %GcpCompute.Error{reason: :operation_failed}}. On timeout, {:error, %GcpCompute.Error{reason: :timeout}}.

Options

  • :timeout — wall-clock budget in ms (default 300000). The deadline is checked between wait/2 calls; since each wait long-polls server-side, an in-flight call may overshoot the deadline by up to ~2 min.

wait(config, operation)

Long-poll an operation once.

Calls the Compute operations.wait endpoint, which blocks server-side until the operation is DONE or ~2 minutes elapse, then returns the current state.