public async Task <IEventStreamConsumer> CreateStreamConsumerAsync(Action <IEventStreamConsumerConfiguration> configure)
        {
            Require.NotNull(configure, "configure");

            var configuration = new EventStreamConsumerConfiguration();

            configure(configuration);
            configuration.AsserConfigurationCompleted();

            m_connectionState.EnsureConnectionIsActive();

            var readerId = await m_consumers.RegisterAsync(configuration.ConsumerName);

            var session = m_sessionFactory.CreateSession(readerId, configuration.StreamName);

            Func <StreamVersion, Task> commitReaderVersion = version => m_journal.CommitStreamReaderPositionAsync(
                streamName: configuration.StreamName,
                readerId: readerId,
                version: version);

            return(new EventStreamConsumer(
                       session: session,
                       readerFactory: new PersistentEventStreamReaderFactory(
                           readerId,
                           m_journal,
                           m_connectionState,
                           m_pipelineFactory.CreateIncomingPipeline(),
                           configuration),
                       autoCommitProcessedStreamVersion: configuration.UseAutoCommitProcessedStreamPositionBehavior,
                       commitConsumedVersion: commitReaderVersion));
        }
        public PersistentEventStreamReaderFactory(
            EventStreamReaderId readerId,
            IEventJournal journal,
            IEventStoreConnectionState connectionState,
            IEventMutationPipeline mutationPipeline,
            EventStreamConsumerConfiguration configuration)
        {
            Require.NotNull(readerId, "readerId");
            Require.NotNull(journal, "journal");
            Require.NotNull(connectionState, "connectionState");
            Require.NotNull(mutationPipeline, "mutationPipeline");
            Require.NotNull(configuration, "configuration");

            m_readerId         = readerId;
            m_journal          = journal;
            m_connectionState  = connectionState;
            m_mutationPipeline = mutationPipeline;
            m_configuration    = configuration;
        }