Exemplo n.º 1
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((ShardName != null ? ShardName.GetHashCode() : 0) * 397) ^ Sequence.GetHashCode());
     }
 }
Exemplo n.º 2
0
 protected AsyncProjectionShardBase(ShardName identifier, ISqlFragment[] eventFilters, DocumentStore store, AsyncOptions options)
 {
     Store        = store;
     Name         = identifier;
     EventFilters = eventFilters;
     Options      = options;
 }
Exemplo n.º 3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (ShardName != null ? ShardName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ SequenceFloor.GetHashCode();
         hashCode = (hashCode * 397) ^ SequenceCeiling.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 4
0
        public DeadLetterEvent(IEvent e, ShardName shardName, ApplyEventException ex)
        {
            ProjectionName   = shardName.ProjectionName;
            ShardName        = shardName.Key;
            Timestamp        = DateTimeOffset.UtcNow;
            ExceptionMessage = ex.Message;

            EventSequence = e.Sequence;

            ExceptionType = ex.InnerException?.GetType().NameInCode();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Use to "wait" for an expected projection shard state
        /// </summary>
        /// <param name="name"></param>
        /// <param name="sequence"></param>
        /// <param name="timeout"></param>
        /// <returns></returns>
        public Task <ShardState> WaitForShardState(ShardName name, long sequence, TimeSpan?timeout = null)
        {
            if (_states.TryFind(name.Identity, out var state))
            {
                if (state.Sequence >= sequence)
                {
                    return(Task.FromResult(state));
                }
            }

            return(WaitForShardState(new ShardState(name.Identity, sequence), timeout));
        }
Exemplo n.º 6
0
        public async Task Load(ShardName projectionShardName, EventRange range, CancellationToken token)
        {
            using var session = (QuerySession)_store.QuerySession();

            // There's an assumption here that this method is only called sequentially
            // and never at the same time on the same instance
            _statement.Range = range;

            try
            {
                range.Events = new List <IEvent>(await session.ExecuteHandlerAsync(_handler, token).ConfigureAwait(false));
            }
            catch (Exception e)
            {
                throw new EventFetcherException(projectionShardName, e);
            }
        }
Exemplo n.º 7
0
        public async Task Load(ShardName projectionShardName, EventRange range, CancellationToken token)
        {
            if (_session == null)
            {
                reset();
            }

            _cancellation.CancelAfter(5.Seconds());

            // There's an assumption here that this method is only called sequentially
            // and never at the same time on the same instance
            _statement.Range = range;

            try
            {
                range.Events = await _session.ExecuteHandlerAsync(_handler, token);
            }
            catch (Exception e)
            {
                throw new EventFetcherException(projectionShardName, e);
            }
        }
Exemplo n.º 8
0
 public AsyncProjectionShard(string shardName, ProjectionSource source, ISqlFragment[] filters)
 {
     Name         = new ShardName(source.ProjectionName, shardName);
     EventFilters = filters.Concat(new ISqlFragment[] { IsNotArchivedFilter.Instance }).ToArray();
     Source       = source;
 }
Exemplo n.º 9
0
 public ProjectionController(ShardName shardName, IProjectionUpdater updater, AsyncOptions options)
 {
     _shardName = shardName;
     _updater   = updater;
     _options   = options ?? new AsyncOptions();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Use to "wait" for an expected projection shard state
 /// </summary>
 /// <param name="name"></param>
 /// <param name="sequence"></param>
 /// <param name="timeout"></param>
 /// <returns></returns>
 public Task <ShardState> WaitForShardState(ShardName name, long sequence, TimeSpan?timeout = null)
 {
     return(WaitForShardState(new ShardState(name.Identity, sequence), timeout));
 }
Exemplo n.º 11
0
 public EventFetcherException(ShardName name, Exception innerException) : base($"Failure while trying to load events for projection shard '{name}'", innerException)
 {
 }
Exemplo n.º 12
0
 public EventRange(ShardName shardName, long ceiling)
 {
     ShardName       = shardName;
     SequenceCeiling = ceiling;
 }
Exemplo n.º 13
0
 public EventFetcherException(ShardName name, IMartenDatabase martenDatabase, Exception innerException) : base($"Failure while trying to load events for projection shard '{name}@{martenDatabase.Identifier}'", innerException)
 {
 }
Exemplo n.º 14
0
 public ShardState(ShardName shardName, long sequence) : this(shardName.Identity, sequence)
 {
 }
Exemplo n.º 15
0
 public AsyncProjectionShard(ProjectionSource source, ISqlFragment[] filters)
 {
     Name         = new ShardName(source.ProjectionName);
     EventFilters = filters;
     Source       = source;
 }
Exemplo n.º 16
0
 public ShardStartException(ShardName name, Exception innerException) : base($"Failure while trying to stop '{name.Identity}'", innerException)
 {
 }
Exemplo n.º 17
0
 public ProjectionController(ShardName shardName, IShardAgent agent, AsyncOptions options)
 {
     _shardName = shardName;
     _agent     = agent;
     _options   = options ?? new AsyncOptions();
 }
Exemplo n.º 18
0
 public AsyncProjectionShard(ShardName identifier, IProjection projection, ISqlFragment[] eventFilters, DocumentStore store,
                             AsyncOptions options) : base(identifier, eventFilters, store, options)
 {
     _projection = projection;
 }