-
Notifications
You must be signed in to change notification settings - Fork 20
eventstream class
Duncan Jones edited this page Oct 31, 2020
·
3 revisions
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.
public EventStream(EventStreamAttribute attribute,
string connectionStringName = "",
IWriteContext context = null)
- DomainName (string) - The name of the domain in which the entity that this event stream is found
- EntityTypeName (string) - The type of the entity for which this event stream is defined
- InstanceKey (string) - The unique identifier of the instance of that entity
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.
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
public async Task<bool> Exists()
Does the event stream identified by the domain/type/instance exist yet?
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).