k8s v0.5.1 K8s.Client.Runner.Async

K8s.Client runner to process a batch of operations in parallel.

Link to this section Summary

Functions

Runs multiple operations in parallel. 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, conn, opts \\ [])

run([K8s.Operation.t()], K8s.Conn.t(), keyword()) :: [
  ok: struct(),
  error: struct()
]

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

Example

Get a list of pods in parallel:

  pods_to_get = [
    %{"name" => "nginx", "namespace" => "default"},
    %{"name" => "redis", "namespace" => "default"}
  ]

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

  # Get the results asynchronously
  {:ok, conn} = K8s.Conn.lookup(:my_cluster)    
  results = K8s.Client.Async.run(operations, conn)