Spear.append
You're seeing just the function
append
, go back to Spear module for more information.
Specs
append( event_stream :: Enumerable.t(), connection :: Spear.Connection.t(), stream_name :: String.t(), opts :: Keyword.t() ) :: :ok | {:error, reason :: Spear.ExpectationViolation.t() | any()}
Appends an enumeration of events to an EventStoreDB stream
event_stream
is an enumerable which may either be a
collection of Spear.Event.t/0
structs or more low-level
Spear.Records.Streams.append_resp/0
records. In cases where the enumerable
produces Spear.Event.t/0
structs, they will be lazily mapped to
Spear.Records.Streams.append_req/0
records before being encoded to wire
data.
See the Writing Events guide for more information about writing events.
Options
:expect
- (default::any
) the expectation to set on the status of the stream. The write will fail if the expectation fails. SeeSpear.ExpectationViolation
for more information about expectations.:timeout
- (default:5_000
- 5s) the GenServer timeout for calling the RPC.:raw?
- (default:false
) a boolean which controls whether the return signature should be a simple:ok | {:error, any()}
or{:ok, AppendResp.t()} | {:error, any()}
. This can be used to extract metadata and information from the append response which is not available through the simplified return API, such as the stream's revision number after writing the events.:credentials
- (default:nil
) a two-tuple{username, password}
to use as credentials for the request. This option overrides any credentials set in the connection configuration, if present. See the Security guide for more details.
Examples
iex> [Spear.Event.new("es_supported_clients", %{})]
...> |> Spear.append(conn, expect: :exists)
:ok
iex> [Spear.Event.new("es_supported_clients", %{})]
...> |> Spear.append(conn, expect: :empty)
{:error, %Spear.ExpectationViolation{current: 1, expected: :empty}}