Skip to content

eventstream class

Duncan Jones edited this page Jun 7, 2019 · 3 revisions

EventStream class

The EventStream class allows you to append events onto a specific event stream for an entity as uniquely identified by the combination of the domain, the entity type and the unique identifier of the entity.

Constructor

  public EventStream(EventStreamAttribute attribute, 
         string connectionStringName = "",
         IWriteContext context = null)

Methods

AppendEvent

public async Task AppendEvent(object eventToAdd,
                              int? expectedTopSequence = null,
                              EventStreamExistenceConstraint streamConstraint = EventStreamExistenceConstraint.Loose)

Appends the given event onto the event stream for the entity.

  • eventToAdd - The instance of the event to append to the end of the event stream
  • expectedTopSequence (Optional) The highest sequence we expect on the event stream. This can be set to prevent an event being written if the actual top of the event stream is higher than the expected top - potentially indicating a data consistency issue.
  • **streamConstraint ** (Optional) A constraint on the existence of the event stream to apply when applying the event.

CreateIfNotExists

public async Task CreateIfNotExists()

Explicitly create the event stream if it does not already exist.
Note that appending an event to an event stream that doesn't yet exist will create a new event stream

Exists

 public async Task<bool> Exists()

Does the event stream identified by the domain/type/instance exist yet?

SetContext

public void SetContext(IWriteContext context)

Set the writer context which is used to "wrap" events written so we know who wrote them (and when and why).

Clone this wiki locally