Ejemplo n.º 1
0
        public Fetcher(IDocumentStore store, DaemonSettings settings, AsyncOptions options, IDaemonLogger logger, IDaemonErrorHandler errorHandler, IEnumerable <Type> eventTypes)
        {
            _settings     = settings;
            _options      = options;
            _logger       = logger;
            _errorHandler = errorHandler;
            State         = FetcherState.Waiting;

            // TODO -- this will have to change
            _tenant = store.Tenancy.Default;

            _streamIdentity = store.Events.StreamIdentity;

            _selector = _tenant.EventStorage();

            EventTypeNames = eventTypes.Select(x => store.Events.EventMappingFor(x).Alias).ToArray();

            var fields = _selector.SelectFields().Join(", ");

            _sql =
                $@"
select seq_id from {_selector.Events.DatabaseSchemaName}.mt_events where seq_id > :last and seq_id <= :limit and extract(epoch from age(transaction_timestamp(), {_selector.Events.DatabaseSchemaName}.mt_events.timestamp)) >= :buffer order by seq_id;
select {fields} from {_selector.Events.DatabaseSchemaName}.mt_events where seq_id > :last and seq_id <= :limit and type = ANY(:types) and extract(epoch from age(transaction_timestamp(), {_selector.Events.DatabaseSchemaName}.mt_events.timestamp)) >= :buffer order by seq_id;
select min(seq_id) from {_selector.Events.DatabaseSchemaName}.mt_events where seq_id > :limit and type = ANY(:types) and extract(epoch from age(transaction_timestamp(), {_selector.Events.DatabaseSchemaName}.mt_events.timestamp)) >= :buffer;
select max(seq_id) from {_selector.Events.DatabaseSchemaName}.mt_events where seq_id >= :limit and extract(epoch from age(transaction_timestamp(), {_selector.Events.DatabaseSchemaName}.mt_events.timestamp)) >= :buffer
".Replace(" as d", "");
        }
Ejemplo n.º 2
0
        public StreamState FetchStreamState(Guid streamId)
        {
            var handler = _tenant.EventStorage().QueryForStream(StreamAction.ForReference(streamId, _tenant));

            return(_session.ExecuteHandler(handler));
        }