private Task WriteAsync(string streamName, StreamPosition position)
        {
            FilterDefinition <StreamPosition> filter = GetStreamFilter(streamName);

            return(collection.ReplaceOneAsync(filter, position, new UpdateOptions
            {
                IsUpsert = true
            }));
        }
        private async Task SaveAsyncInternall(string streamName, long pos)
        {
            StreamPosition entry = await GetOrCreate(streamName);

            entry.TimestampUTC = DateTime.UtcNow;
            entry.Position     = pos;

            await WriteAsync(streamName, entry);
        }
Ejemplo n.º 3
0
        private Task WriteAsync(string streamName, StreamPosition position)
        {
            var filter = GetStreamFilter(streamName);

            return(collection.ReplaceOneAsync(filter, position, new ReplaceOptions()
            {
                IsUpsert = true
            }));
        }
        private async Task <StreamPosition> GetOrCreate(string streamName)
        {
            StreamPosition entry = await ReadAsync(streamName) ?? new StreamPosition
            {
                Id         = streamName.ToLowerInvariant(),
                StreamName = streamName,
                CreatedUTC = DateTime.UtcNow
            };

            return(entry);
        }
        public async Task <long?> GetAsync(string streamName)
        {
            StreamPosition entry = await ReadAsync(streamName);

            return(entry?.Position);
        }