コード例 #1
0
ファイル: EventFetchers.cs プロジェクト: srudaa/Runtime
        /// <inheritdoc/>
        public async Task <ICanFetchEventsFromStream> GetFetcherFor(ScopeId scopeId, IStreamDefinition streamDefinition, CancellationToken cancellationToken)
        {
            if (streamDefinition.StreamId == StreamId.EventLog)
            {
                return(await CreateStreamFetcherForEventLog(scopeId, cancellationToken).ConfigureAwait(false));
            }

            if (streamDefinition.Public)
            {
                return(CreateStreamFetcherForStreamEventCollection(
                           await _streams.GetPublic(streamDefinition.StreamId, cancellationToken).ConfigureAwait(false),
                           streamDefinition.StreamId,
                           streamDefinition.Partitioned));
            }

            return(CreateStreamFetcherForStreamEventCollection(
                       await _streams.Get(scopeId, streamDefinition.StreamId, cancellationToken).ConfigureAwait(false),
                       streamDefinition.StreamId,
                       streamDefinition.Partitioned));
        }
コード例 #2
0
 /// <inheritdoc/>
 public async Task Write(CommittedEvent @event, ScopeId scope, StreamId stream, PartitionId partition, CancellationToken cancellationToken)
 {
     _logger.Trace("Writing Event: {EventLogSequenceNumber} to Stream: {Stream} in Scope: {Scope}", @event.EventLogSequenceNumber, stream, scope);
     await Write(
         await _streams.Get(scope, stream, cancellationToken).ConfigureAwait(false),
         _streamFilter,
         streamPosition =>
         @event is CommittedExternalEvent externalEvent?
         _eventConverter.ToStoreStreamEvent(externalEvent, streamPosition, partition)
         : _eventConverter.ToStoreStreamEvent(@event, streamPosition, partition),
         cancellationToken).ConfigureAwait(false);
 }
コード例 #3
0
    /// <inheritdoc/>
    public async Task Write(CommittedEvent @event, ScopeId scope, StreamId stream, PartitionId partition, CancellationToken cancellationToken)
    {
        _logger.WritingEventToStream(@event.EventLogSequenceNumber, stream, scope);
        var writtenStreamPosition = await Write(
            await _streams.Get(scope, stream, cancellationToken).ConfigureAwait(false),
            _streamFilter,
            streamPosition =>
            @event is CommittedExternalEvent externalEvent?
            _eventConverter.ToStoreStreamEvent(externalEvent, streamPosition, partition)
            : _eventConverter.ToStoreStreamEvent(@event, streamPosition, partition),
            cancellationToken).ConfigureAwait(false);

        _streamWatcher.NotifyForEvent(scope, stream, writtenStreamPosition);
    }