本文整理汇总了C#中EventStore.Projections.Core.Services.Processing.EmittedEventEnvelope类的典型用法代码示例。如果您正苦于以下问题:C# EmittedEventEnvelope类的具体用法?C# EmittedEventEnvelope怎么用?C# EmittedEventEnvelope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmittedEventEnvelope类属于EventStore.Projections.Core.Services.Processing命名空间,在下文中一共展示了EmittedEventEnvelope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessEvent
public bool ProcessEvent(
string partition, CheckpointTag eventPosition, string category1, ResolvedEvent data,
out string newState, out string newSharedState, out EmittedEventEnvelope[] emittedEvents)
{
newSharedState = null;
emittedEvents = null;
newState = null;
var category = _streamCategoryExtractor.GetCategoryByStreamId(data.PositionStreamId);
if (category == null)
return true; // handled but not interesting
string linkTarget;
if (data.EventType == SystemEventTypes.LinkTo)
linkTarget = data.Data;
else
linkTarget = data.EventSequenceNumber + "@" + data.EventStreamId;
emittedEvents = new[]
{
new EmittedEventEnvelope(
new EmittedLinkToWithRecategorization(
_categoryStreamPrefix + category, Guid.NewGuid(), linkTarget, eventPosition, expectedTag: null,
originalStreamId: data.PositionStreamId))
};
return true;
}
示例2: ProcessEvent
public bool ProcessEvent(
string partition, CheckpointTag eventPosition, string category1, ResolvedEvent data,
out string newState, out EmittedEventEnvelope[] emittedEvents)
{
emittedEvents = null;
newState = null;
if (data.PositionStreamId.StartsWith("$"))
return false;
var lastSlashPos = data.PositionStreamId.LastIndexOf(_separator);
if (lastSlashPos < 0)
return true; // handled but not interesting to us
var category = data.PositionStreamId.Substring(0, lastSlashPos);
string linkTarget;
if (data.EventType == SystemEventTypes.LinkTo)
linkTarget = data.Data;
else
linkTarget = data.EventSequenceNumber + "@" + data.EventStreamId;
emittedEvents = new[]
{
new EmittedEventEnvelope(
new EmittedLinkToWithRecategorization(
_categoryStreamPrefix + category, Guid.NewGuid(), linkTarget, eventPosition, expectedTag: null,
originalStreamId: data.PositionStreamId))
};
return true;
}
示例3: CreateResultUpdatedEvents
private EmittedEventEnvelope[] CreateResultUpdatedEvents(string partition, string projectionResult, CheckpointTag at)
{
var streamId = _namesBuilder.MakePartitionResultStreamName(partition);
var allResultsStreamId = _namesBuilder.GetResultStreamName();
if (string.IsNullOrEmpty(partition))
{
var result =
new EmittedEventEnvelope(
projectionResult == null
? new EmittedDataEvent(
streamId, Guid.NewGuid(), "ResultRemoved", true, null, null, at, null)
: new EmittedDataEvent(
streamId, Guid.NewGuid(), "Result", true, projectionResult, null, at, null),
_resultStreamMetadata);
return new[] {result};
}
else
{
var linkTo = new EmittedLinkTo(allResultsStreamId, Guid.NewGuid(), streamId, at, null);
var linkToEnvelope = new EmittedEventEnvelope(linkTo, _resultStreamMetadata);
var result =
new EmittedEventEnvelope(
projectionResult == null
? new EmittedDataEvent(
streamId, Guid.NewGuid(), "ResultRemoved", true, null, null, at, null,
linkTo.SetTargetEventNumber)
: new EmittedDataEvent(
streamId, Guid.NewGuid(), "Result", true, projectionResult, null, at, null,
linkTo.SetTargetEventNumber), _resultStreamMetadata);
return new[] {result, linkToEnvelope};
}
}
示例4: ProcessEvent
public bool ProcessEvent(
string partition, CheckpointTag eventPosition, string category, ResolvedEvent data, out string newState,
out string newSharedState, out EmittedEventEnvelope[] emittedEvents)
{
newSharedState = null;
if (!data.EventStreamId.StartsWith(UserStreamPrefix))
throw new InvalidOperationException(
string.Format(
"Invalid stream name: '{0}' The IndexUsersProjectionHandler cannot handle events from other streams than named after the '$user-' pattern",
data.EventStreamId));
var loginName = data.EventStreamId.Substring(UserStreamPrefix.Length);
var userData = data.Data.ParseJson<UserData>();
if (userData.LoginName != loginName)
throw new InvalidOperationException(
string.Format(
"Invalid $UserCreated event found. '{0}' login name expected, but '{1}' found", loginName,
userData.LoginName));
emittedEvents = new[]
{
new EmittedEventEnvelope(
new EmittedDataEvent(
UsersStream, Guid.NewGuid(), UserEventType, false, loginName, null, eventPosition, null))
};
newState = "";
return true;
}
示例5: ProcessEvent
public bool ProcessEvent(
string partition, CheckpointTag eventPosition, string category1, ResolvedEvent data,
out string newState, out string newSharedState, out EmittedEventEnvelope[] emittedEvents)
{
newSharedState = null;
emittedEvents = null;
newState = null;
if (data.EventStreamId != data.PositionStreamId)
return false;
var indexedEventType = data.EventType;
if (indexedEventType == "$>")
return false;
string positionStreamId;
var isStreamDeletedEvent = StreamDeletedHelper.IsStreamDeletedEvent(
data.PositionStreamId, data.EventType, data.Data, out positionStreamId);
if (isStreamDeletedEvent)
indexedEventType = "$deleted";
emittedEvents = new[]
{
new EmittedEventEnvelope(
new EmittedDataEvent(
_indexStreamPrefix + indexedEventType, Guid.NewGuid(), "$>", false,
data.EventSequenceNumber + "@" + positionStreamId,
isStreamDeletedEvent
? new ExtraMetaData(new Dictionary<string, JRaw> {{"$deleted", new JRaw(-1)}})
: null, eventPosition, expectedTag: null))
};
return true;
}
示例6: ProcessEvent
public bool ProcessEvent(
string partition, CheckpointTag eventPosition, string category1, ResolvedEvent data,
out string newState, out string newSharedState, out EmittedEventEnvelope[] emittedEvents)
{
newSharedState = null;
emittedEvents = null;
newState = null;
if (data.PositionSequenceNumber != 0)
return false; // not our event
var category = _streamCategoryExtractor.GetCategoryByStreamId(data.PositionStreamId);
if (category == null)
return true; // handled but not interesting
emittedEvents = new[]
{
new EmittedEventEnvelope(
new EmittedDataEvent(
"$category" + "-" + category, Guid.NewGuid(), SystemEventTypes.StreamReference, false,
data.PositionStreamId, null, eventPosition, expectedTag: null))
};
return true;
}
示例7: ProcessEvent
public bool ProcessEvent(
string partition, CheckpointTag eventPosition, string category1, ResolvedEvent data,
out string newState, out EmittedEventEnvelope[] emittedEvents)
{
emittedEvents = null;
newState = null;
if (data.PositionSequenceNumber != 0)
return false; // not our event
if (data.EventStreamId.StartsWith("$"))
return false;
var lastSlashPos = data.EventStreamId.LastIndexOf(_separator);
if (lastSlashPos < 0)
return true; // handled but not interesting to us
var category = data.EventStreamId.Substring(0, lastSlashPos);
emittedEvents = new[]
{
new EmittedEventEnvelope(
new EmittedDataEvent(
"$category" + _separator + category, Guid.NewGuid(), SystemEventTypes.StreamReference, false,
data.EventStreamId, null, eventPosition, expectedTag: null))
};
return true;
}
示例8: ProcessEvent
public bool ProcessEvent(
string partition, CheckpointTag eventPosition, string category1, ResolvedEvent data,
out string newState, out EmittedEventEnvelope[] emittedEvents)
{
emittedEvents = null;
newState = null;
return true;
}
示例9: UpdateLastPosition
private void UpdateLastPosition(EmittedEventEnvelope[] events)
{
foreach (var emittedEvent in events)
{
if (emittedEvent.Event.CausedByTag > _last)
_last = emittedEvent.Event.CausedByTag;
}
}
示例10: ProcessEvent
public bool ProcessEvent(
string partition, CheckpointTag eventPosition, string category1, ResolvedEvent data,
out string newState, out EmittedEventEnvelope[] emittedEvents)
{
if (data.EventType == "fail" || _query == "fail")
throw new Exception("failed");
_logger("ProcessEvent(" + "..." + ")");
newState = "{\"data\": " + _state + data + "}";
emittedEvents = null;
return true;
}
示例11: ValidateOrderAndEmitEvents
public void ValidateOrderAndEmitEvents(EmittedEventEnvelope[] events)
{
UpdateLastPosition(events);
EnsureCheckpointNotRequested();
var groupedEvents = events.GroupBy(v => v.Event.StreamId);
foreach (var eventGroup in groupedEvents)
{
EmitEventsToStream(eventGroup.Key, eventGroup.ToArray());
}
}
示例12: ProcessEvent
public static bool ProcessEvent(
this IProjectionStateHandler self, string partition, CheckpointTag eventPosition, string streamId,
string eventType, string category, Guid eventId, int eventSequenceNumber, string metadata, string data,
out string state, out EmittedEventEnvelope[] emittedEvents, bool isJson = true)
{
return self.ProcessEvent(
partition, eventPosition, category,
new ResolvedEvent(
streamId, eventSequenceNumber, streamId, eventSequenceNumber, false, new TFPos(0, -1),
eventId, eventType, isJson, data, metadata), out state, out emittedEvents);
}
示例13: EventProcessedResult
public EventProcessedResult(
string partition, CheckpointTag checkpointTag, PartitionState oldState, PartitionState newState,
EmittedEventEnvelope[] emittedEvents, Guid causedBy, string correlationId)
{
if (partition == null) throw new ArgumentNullException("partition");
if (checkpointTag == null) throw new ArgumentNullException("checkpointTag");
_emittedEvents = emittedEvents;
_causedBy = causedBy;
_correlationId = correlationId;
_oldState = oldState;
_newState = newState;
_partition = partition;
_checkpointTag = checkpointTag;
}
示例14: ProcessEvent
public bool ProcessEvent(
string partition, CheckpointTag eventPosition, string category1, ResolvedEvent data,
out string newState, out EmittedEventEnvelope[] emittedEvents)
{
emittedEvents = null;
newState = null;
if (data.EventSequenceNumber != 0 || data.ResolvedLinkTo)
return false; // not our event
emittedEvents = new[]
{
new EmittedEventEnvelope(
new EmittedDataEvent(
SystemStreams.StreamsStream, Guid.NewGuid(), SystemEventTypes.LinkTo, false,
data.EventSequenceNumber + "@" + data.EventStreamId, null, eventPosition, expectedTag: null))
};
return true;
}
示例15: ProcessEvent
public bool ProcessEvent(
string partition, CheckpointTag eventPosition, string category1, ResolvedEvent data,
out string newState, out EmittedEventEnvelope[] emittedEvents)
{
emittedEvents = null;
newState = null;
if (data.EventStreamId != data.PositionStreamId)
return false;
if (data.EventType == "$>")
return false;
emittedEvents = new[]
{
new EmittedEventEnvelope(
new EmittedDataEvent(
_indexStreamPrefix + data.EventType, Guid.NewGuid(), "$>", false,
data.EventSequenceNumber + "@" + data.EventStreamId, null, eventPosition, expectedTag: null))
};
return true;
}