Xirsys.Sockets.Accumulator.Reorder (xturn_sockets v2.2.0)

View Source

Reordering decorator over any inner Accumulator.

Whole packets from the inner accumulator are tagged with an integer key via key_fun.(packet, meta). Keys must be contiguous for in-order release, starting at the first key observed. Packets tagged :unordered skip the reorder buffer.

Options

  • :inner - inner accumulator module (default: Accumulator.Raw)
  • :inner_opts - options passed to inner.init/1
  • :key_fun - required (packet, meta) -> integer() | :unordered

  • :name - config lookup key for Config.reorder_opts/2
  • :window, :max_delay_ms, :on_overflow, :enabled - tunables via config and/or explicit opts (Config.reorder_opts/2)
  • :clock - injectable clock, defaults to System.monotonic_time/1
  • :max_size - bound on the ready queue (default: 1024)

Summary

Functions

Builds reorder state. Raises if :key_fun is missing.

Releases the next in-order packet, or {:more, acc} while a gap remains.

Pushes chunk into the inner accumulator.

Functions

init(opts)

Builds reorder state. Raises if :key_fun is missing.

Parameters

  • opts - see module options

    iex> keyfun = fn <<n, ::binary>>, -> n end iex> acc = Xirsys.Sockets.Accumulator.Reorder.init(key_fun: key_fun) iex> acc = ...> acc ...> |> Xirsys.Sockets.Accumulator.Reorder.push(<<2>>, %{}) ...> |> Xirsys.Sockets.Accumulator.Reorder.push(<<1>>, %{}) iex> {:ok, <<1>>, , acc} = Xirsys.Sockets.Accumulator.Reorder.pop(acc) iex> {:ok, <<2>>, _, acc} = Xirsys.Sockets.Accumulator.Reorder.pop(acc) iex> elem(Xirsys.Sockets.Accumulator.Reorder.pop(acc), 0) :more

pop(acc)

Releases the next in-order packet, or {:more, acc} while a gap remains.

Parameters

push(acc, chunk, meta)

Pushes chunk into the inner accumulator.

Parameters

  • acc - state from init/1
  • chunk - bytes for the inner accumulator
  • meta - forwarded to key_fun after the inner pop/1