k8s v0.2.8 K8s.Client.Runner.Async

K8s.Client runner to process a batch of operations asynchronously.

Link to this section Summary

Functions

Async run multiple operations. Operations will be returned in same order given. Operations will not cease in event of failure.

Link to this section Functions

Link to this function

run(operations, cluster_name, opts \\ [])
run([K8s.Operation.t()], binary(), keyword()) :: [ok: struct(), error: struct()]

Async run multiple operations. Operations will be returned in same order given. Operations will not cease in event of failure.

Example

Get a list of pods, then map each one to an individual GET operation:

  # Get the pods
  operation = K8s.Client.list("v1", "Pod", namespace: :all)
  {:ok, %{"items" => pods}} = K8s.Client.run(operation, "test-cluster")

  # Map each one to an individual `GET` operation.
  operations = Enum.map(pods, fn(%{"metadata" => %{"name" => name, "namespace" => ns}}) ->
     K8s.Client.get("v1", "Pod", namespace: ns, name: name)
  end)

  # Get the results asynchronously
  results = K8s.Client.Async.run(operations, "test-cluster")