Append
Append Events to Streams.
WrongExpectedVersionError
Bases: Exception
Occurs when an event is appended with the wrong expected version.
Source code in src/eventstore_grpc/streams/append.py
append_to_stream(stub, stream, expected_version, events, user_credentials, **kwargs)
Appends an Event to an Event Stream.
Write one or more events to a stream, atomically. You do this by appending the events to the stream in one operation, or by using transations.
Note that sending events to a non-existing stream, implicitly creates the stream.
It is possible to make an optimistic concurrency check during the write by specifying the version at which you expect the stream to be.
Identical write operations are idempotent if the optimistic concurrency check is not disabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream |
str
|
A string identifying the stream to which to append. |
required |
expected_version |
Union[str, int]
|
the version at which you expect the stream to be in order that an optimistic concurrency check can be performed. This should either be a positive integer or a string, with possible values being "NO_STREAM" or "EMPTY_STREAM", or "ANY" (to disable the check). |
required |
events |
Union[EventData, List[EventData]]
|
event or list of events to append. |
required |
user_credentials |
UserCredentials | None
|
specify the user on behalf whom write will be executed. |
required |
Source code in src/eventstore_grpc/streams/append.py
build_options(stream, expected_version=None)
Builds AppendReq Options.
Source code in src/eventstore_grpc/streams/append.py
build_options_request(stream, expected_version)
Builds an Options message for AppendReq.
Source code in src/eventstore_grpc/streams/append.py
build_proposed_message_request(event)
Builds AppendReq Proposed Message.
Source code in src/eventstore_grpc/streams/append.py
build_request_stream(stream, expected_version, events)
Builds the AppendReq stream.
Source code in src/eventstore_grpc/streams/append.py
handle_wrong_expected_version(message)
Handles append error.