View Source Bonny.Server.AsyncStreamRunner (bonny v1.4.0)

Runs the given stream in a separate process. Prepare your stream and add this Runner to your supervision tree in order to control it (e.g. restart after the stream ends).

Example

# prepare a stream
stream =
  conn
  |> K8s.Client.stream(operation)
  |> Stream.filter(&filter_resources/1)
  |> Stream.map(&process_stream/1)

children = [
  {Bonny.Server.AsyncStreamRunner,
     name: ReconcileServer,
     stream: stream,
     termination_delay: 30_000,
]

Supervisor.init(children, strategy: :one_for_one)

Options

  • :stream - The (prepared) stream to run
  • :name (optional) - Register this process under the given name.
  • :termination_delay (optional) - After the stream ends, how many milliseconds to wait before the process terminates (and might be restarted by the Supervisor). Per default there's no delay

Summary

Functions

@spec child_spec(keyword()) :: Supervisor.child_spec()
Link to this function

run(stream, termination_delay)

View Source
@spec run(Enumerable.t(), non_neg_integer()) :: no_return()
@spec start_link(keyword()) :: {:ok, pid()}