You're seeing just the callback append_to_stream, go back to EventStore module for more information.
Link to this callback

append_to_stream(stream_uuid, expected_version, events, opts)

View Source


  stream_uuid :: String.t(),
  events :: [EventStore.EventData.t()],
  opts :: options()
) ::
  | {:error, :cannot_append_to_all_stream}
  | {:error, :stream_exists}
  | {:error, :stream_not_found}
  | {:error, :wrong_expected_version}
  | {:error, :stream_deleted}
  | {:error, reason :: term()}

Append one or more events to a stream atomically.

  • stream_uuid is used to uniquely identify a stream.

  • expected_version is used for optimistic concurrency checks. You can provide a non-negative integer to specify the expected stream version. This is used to ensure you can only append to the stream if it is at exactly that version.

    You can also provide one of the following values to alter the concurrency check behaviour:

    • :any_version - No concurrency checking and allow any stream version (including no stream).
    • :no_stream - Ensure the stream does not exist.
    • :stream_exists - Ensure the stream exists.
  • events is a list of %EventStore.EventData{} structs.

  • opts an optional keyword list containing:

    • name the name of the event store if provided to start_link/1.
    • timeout an optional timeout for the database transaction, in milliseconds. Defaults to 15,000ms.

Returns :ok on success, or an {:error, reason} tagged tuple. The returned error may be due to one of the following reasons:

  • {:error, :wrong_expected_version} when the actual stream version differs from the provided expected version.
  • {:error, :stream_exists} when the stream exists, but expected version was :no_stream.
  • {:error, :stream_not_found} when the stream does not exist, but expected version was :stream_exists.