Real-World Event Sourcing: broadcast_message usage and explanation

Real-World Event Sourcing: broadcast_message usage and explanation

  • Page: 61
  • Version: B2.0
  • Book type: EPUB

The function broadcast_message/1 is defined but never actually invoked in the examples, and its explanation is too brief.

The broadcast_message function is to be called by whatever component wishes to perform an injection. The message (if necessary) is converted into a cloud event and then passed down to any interested stage consumers.

Function definition:

  @doc """
  Injects a raw message that is not in cloud event format
  """
  def broadcast_message(message) do
    GenStage.call(__MODULE__, {:notify, message})
  end

However, the current text does not show who should call it, nor does it provide an example of usage in the context of the pipeline. This leaves readers uncertain about when and how to use it.

Suggested improvement:

  • Clarify in the text which components are expected to call broadcast_message/1.
  • Provide a small code snippet showing a realistic call (e.g., from an external producer or test) so that readers can see the injection mechanism in action.