Exemple #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((ShardName != null ? ShardName.GetHashCode() : 0) * 397) ^ Sequence.GetHashCode());
     }
 }
Exemple #2
0
 protected AsyncProjectionShardBase(ShardName identifier, ISqlFragment[] eventFilters, DocumentStore store, AsyncOptions options)
 {
     Store        = store;
     Name         = identifier;
     EventFilters = eventFilters;
     Options      = options;
 }
Exemple #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);
     }
 }
Exemple #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();
        }
        /// <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));
        }
Exemple #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);
            }
        }
Exemple #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);
            }
        }
 public AsyncProjectionShard(string shardName, ProjectionSource source, ISqlFragment[] filters)
 {
     Name         = new ShardName(source.ProjectionName, shardName);
     EventFilters = filters.Concat(new ISqlFragment[] { IsNotArchivedFilter.Instance }).ToArray();
     Source       = source;
 }
Exemple #9
0
 public ProjectionController(ShardName shardName, IProjectionUpdater updater, AsyncOptions options)
 {
     _shardName = shardName;
     _updater   = updater;
     _options   = options ?? new AsyncOptions();
 }
 /// <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));
 }
Exemple #11
0
 public EventFetcherException(ShardName name, Exception innerException) : base($"Failure while trying to load events for projection shard '{name}'", innerException)
 {
 }
Exemple #12
0
 public EventRange(ShardName shardName, long ceiling)
 {
     ShardName       = shardName;
     SequenceCeiling = ceiling;
 }
Exemple #13
0
 public EventFetcherException(ShardName name, IMartenDatabase martenDatabase, Exception innerException) : base($"Failure while trying to load events for projection shard '{name}@{martenDatabase.Identifier}'", innerException)
 {
 }
Exemple #14
0
 public ShardState(ShardName shardName, long sequence) : this(shardName.Identity, sequence)
 {
 }
Exemple #15
0
 public AsyncProjectionShard(ProjectionSource source, ISqlFragment[] filters)
 {
     Name         = new ShardName(source.ProjectionName);
     EventFilters = filters;
     Source       = source;
 }
Exemple #16
0
 public ShardStartException(ShardName name, Exception innerException) : base($"Failure while trying to stop '{name.Identity}'", innerException)
 {
 }
 public ProjectionController(ShardName shardName, IShardAgent agent, AsyncOptions options)
 {
     _shardName = shardName;
     _agent     = agent;
     _options   = options ?? new AsyncOptions();
 }
Exemple #18
0
 public AsyncProjectionShard(ShardName identifier, IProjection projection, ISqlFragment[] eventFilters, DocumentStore store,
                             AsyncOptions options) : base(identifier, eventFilters, store, options)
 {
     _projection = projection;
 }