Struct eventstore_tcp::builder::WriteEventsBuilder
[−]
[src]
pub struct WriteEventsBuilder { /* fields omitted */ }
Builder for WriteEvents
which allows writing multiple events to a stream.
Example
use eventstore_tcp::{Builder, ExpectedVersion, StreamVersion, ContentType}; let package = Builder::write_events() .stream_id("my_stream-1") .expected_version(StreamVersion::from(42)) .new_event() .event_type("meaning_of_life") .data("{ 'meaning': 42 }".as_bytes()) .data_content_type(ContentType::Json) .done() .new_event() .event_type("meaning_of_life") .data("{ 'meaning': 47 }".as_bytes()) .data_content_type(ContentType::Json) .done() .require_master(false) // default .build_package(None, None);
Methods
impl WriteEventsBuilder
[src]
fn stream_id<S: Into<Cow<'static, str>>>(&mut self, id: S) -> &mut Self
Panics if the id is an empty string
fn expected_version<V: Into<ExpectedVersion>>(&mut self,
version: V)
-> &mut Self
version: V)
-> &mut Self
Sets the expected version of the stream as an optimistic locking mechanism.
fn require_master(&mut self, require: bool) -> &mut Self
Should the server only handle the request if it is the cluster master. Note that while only the master server can accept writes, other cluster members can forward requests to the master.
Defaults to false
.
fn new_event<'b>(&'b mut self) -> NewEventBuilder<'b>
Start creating a new event using NewEventBuilder
.
fn build_package(&mut self,
authentication: Option<UsernamePassword>,
correlation_id: Option<Uuid>)
-> Package
authentication: Option<UsernamePassword>,
correlation_id: Option<Uuid>)
-> Package
Build a package. Will panic if required values are not set. Values of this builder will be moved into the package.