Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specs/grains observation #1573

Merged
merged 70 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
0cbaec5
Add more specs
woksin Nov 22, 2024
928d841
Rework FailedPartition related concepts
woksin Nov 22, 2024
2314751
Improve code a bit
woksin Nov 22, 2024
3a5ee4e
Correct namespace for FailedPartitionGrainStorageProvider
woksin Nov 22, 2024
b7f26c3
Improve ObserverLogging
woksin Nov 22, 2024
10fa1cb
Some refactoring and cleanup
woksin Nov 22, 2024
6aa260f
Refactoring and cleanup
woksin Nov 22, 2024
2d7edf0
Cleaning
woksin Nov 25, 2024
cb87799
Specs for FailedPartitionGrainStorageProvider
woksin Nov 25, 2024
567ca7a
Make it build
woksin Nov 25, 2024
9fa764a
Make it build in release
woksin Nov 25, 2024
8a89a98
Use MoveNextAsync instead of sync MoveNext
woksin Nov 25, 2024
3899407
Add ReplayingPartitions to ObserverState
woksin Nov 25, 2024
f7e9463
Add specs for observer with replaying partitions
woksin Nov 25, 2024
12eed8b
Add more log messages to the Observer
woksin Nov 25, 2024
a3dedd4
Minor code cleanup
woksin Nov 25, 2024
94ab4b9
Add CatchingUpPartitions to ObserverState
woksin Nov 25, 2024
b31499d
Add interface for CatchUpObserverPartition job
woksin Nov 25, 2024
1420253
Code cleanup
woksin Nov 25, 2024
ada399c
Add last handled event sequence number to HandleEvnetsForPartitionResult
woksin Nov 25, 2024
26d33a4
Add more log messages to Observer
woksin Nov 25, 2024
705360e
Add methods and some parameters to IObserver for correctly handling c…
woksin Nov 25, 2024
e5242a3
Change method name
woksin Nov 25, 2024
12f5e5d
Remove Handled from ObserverState
woksin Nov 26, 2024
1423c79
Delete unnecessary code
woksin Nov 26, 2024
b555e7d
Add AllStepsCompletedSuccessfully bool to Job
woksin Nov 26, 2024
333f04a
Expose saving JobStep grain state to inheriting classes and fix Pause…
woksin Nov 26, 2024
1cc26d3
Modify HandleEventsFOrPartition so that it supports keeping its own s…
woksin Nov 26, 2024
1c29d7a
Fix doc
woksin Nov 26, 2024
18322cd
WIP
woksin Nov 26, 2024
181ecdb
Fix Observation Jobs
woksin Nov 26, 2024
7c170de
Make it build
woksin Nov 26, 2024
ed14f1d
Make it build in release
woksin Nov 26, 2024
f4e3685
Correct observer specs
woksin Nov 26, 2024
d472443
Add spec for observer handling for when event handling did not have a…
woksin Nov 26, 2024
6a7abc4
Change ObserverSubscriberResult.Disconnected to not take an argument …
woksin Nov 26, 2024
ab4997c
Fix some specification instances for Observer
woksin Nov 26, 2024
9be96e8
Fix Observer based on specs
woksin Nov 26, 2024
cdbfec7
Remove unneeded parameter from Observer method
woksin Nov 26, 2024
3b87fb7
Also update ObserverState when notifying that partition have been rep…
woksin Nov 26, 2024
397cac7
Add specs
woksin Nov 26, 2024
0dfbeda
Merge branch 'main' of github.com:Cratis/Cratis into specs/grains-obs…
woksin Nov 26, 2024
f091e22
Fix build issues
woksin Nov 27, 2024
593324d
Merge branch 'main' of github.com:Cratis/Cratis into specs/grains-obs…
woksin Nov 27, 2024
fa77b56
Merge branch 'fix/dotnet-upgrade' into specs/grains-observation
woksin Nov 27, 2024
7aa09f8
Merge branch 'fix/dotnet-upgrade' into specs/grains-observation
woksin Nov 27, 2024
fb8ad27
Merge branch 'fix/dotnet-upgrade' into specs/grains-observation
woksin Nov 27, 2024
c416a48
Make the specs pass
woksin Nov 27, 2024
f47fd80
Specs for Observer notifying replayed partition
woksin Nov 28, 2024
024eb42
Small fixes
woksin Nov 28, 2024
1eaa9c2
Rename method
woksin Nov 28, 2024
b98d5f5
Remove unnecessary usings
woksin Nov 28, 2024
04bbe48
Unecessary usings
woksin Nov 28, 2024
869d583
Add and improve specs for Observer
woksin Nov 28, 2024
ee844ce
Add specs to Observer
woksin Nov 28, 2024
0ed059e
Fix grammar
woksin Nov 28, 2024
c9bdbdc
Start on specs for job system
woksin Nov 28, 2024
2d52da8
Add log message and clean up HandleEventsForPartition a bit
woksin Nov 28, 2024
64cf678
Fix build issues
woksin Nov 28, 2024
d084778
Add a fail-safe mechanism in integration tests GlobalFixture that ret…
woksin Nov 28, 2024
934569b
Merge branch 'fix/dotnet-upgrade' of github.com:Cratis/Cratis into sp…
woksin Nov 28, 2024
8696063
Merge branch 'fix/dotnet-upgrade' of github.com:Cratis/Cratis into sp…
woksin Nov 28, 2024
2149704
Merge branch 'main' of github.com:Cratis/Cratis into specs/grains-obs…
woksin Nov 28, 2024
4156d36
Unnecessary using
woksin Nov 28, 2024
4a7b5a3
Update Source/Api/Api.csproj
woksin Nov 28, 2024
74b449f
Fux EvebtObservationState in CatchUpObserverPartition
woksin Nov 28, 2024
3726662
Merge branch 'main' of github.com:Cratis/Cratis into specs/grains-obs…
woksin Nov 28, 2024
ee569d4
Update Source/Kernel/Concepts/Observation/FailedPartitions.cs
woksin Nov 29, 2024
214a772
Update Source/Kernel/Grains/Observation/Jobs/HandleEventsForPartition.cs
woksin Nov 29, 2024
c2fbd9d
Fix build error
woksin Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ dotnet_diagnostic.CA2000.severity = none
dotnet_diagnostic.CA2201.severity = none
dotnet_diagnostic.CA2211.severity = none
dotnet_diagnostic.CA2252.severity = none
dotnet_diagnostic.CS0108.severity = none
dotnet_diagnostic.CS8600.severity = none
dotnet_diagnostic.CS8601.severity = none
dotnet_diagnostic.CS8602.severity = none
Expand All @@ -153,6 +154,7 @@ dotnet_diagnostic.IDE0005.severity = none
dotnet_diagnostic.IDE0044.severity = none
dotnet_diagnostic.IDE0051.severity = none
dotnet_diagnostic.IDE0052.severity = none
dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.IDE0060.severity = none
dotnet_diagnostic.IDE0240.severity = none
dotnet_diagnostic.IDE1006.severity = none
Expand Down Expand Up @@ -196,3 +198,4 @@ dotnet_diagnostic.MA0069.severity = none
dotnet_diagnostic.MA0096.severity = none
dotnet_diagnostic.MA0097.severity = none
dotnet_diagnostic.MA0132.severity = none
dotnet_diagnostic.MA0134.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ async Task Because()
[Fact]
void should_have_correct_observer_state_next_event_sequence_number_for_event_types() => Context.ReactorObserverState.NextEventSequenceNumberForEventTypes.Value.ShouldEqual(EventSequenceNumber.Unavailable.Value);

[Fact]
void should_have_correct_observer_state_handled_number() => Context.ReactorObserverState.Handled.ShouldEqual(1);

[Fact]
void should_not_have_failed_partitions() => Context.FailedPartitions.HasFailedPartitions.ShouldBeFalse();
}
2 changes: 1 addition & 1 deletion Source/Api/Observation/ObserverCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task TryRecoverFailedPartition(
[FromRoute] ObserverId observerId,
[FromRoute] string partition)
{
await grainFactory.GetGrain<IObserver>(new ObserverKey(observerId, eventStore, @namespace, EventSequenceId.Log)).TryRecoverFailedPartition(partition);
await grainFactory.GetGrain<IObserver>(new ObserverKey(observerId, eventStore, @namespace, EventSequenceId.Log)).TryStartRecoverJobForFailedPartition(partition);
}

/// <summary>
Expand Down
14 changes: 12 additions & 2 deletions Source/Infrastructure/Properties/ArrayIndexers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class ArrayIndexers

readonly IDictionary<PropertyPath, ArrayIndexer> _arrayIndexers = new Dictionary<PropertyPath, ArrayIndexer>();

int? _computedHashCode;

/// <summary>
/// Initializes a new instance of the <see cref="ArrayIndexers"/> class.
/// </summary>
Expand All @@ -37,7 +39,7 @@ public ArrayIndexers(IEnumerable<ArrayIndexer> arrayIndexers)
public int Count => _arrayIndexers.Count;

/// <summary>
/// Gets a value indicating whether or not it is empty.
/// Gets a value indicating whether it is empty.
/// </summary>
public bool IsEmpty => _arrayIndexers.Count == 0;

Expand Down Expand Up @@ -81,7 +83,15 @@ public override bool Equals(object? obj)
}

/// <inheritdoc/>
public override int GetHashCode() => base.GetHashCode();
public override int GetHashCode()
{
// From https://stackoverflow.com/a/8094931
unchecked
{
_computedHashCode ??= All.Aggregate(19, (current, item) => (current * 31) + item.GetHashCode());
return _computedHashCode.Value;
}
}

void ThrowIfMissingArrayIndexerForPropertyPath(PropertyPath propertyPath)
{
Expand Down
5 changes: 3 additions & 2 deletions Source/Kernel/Concepts/Observation/FailedPartition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public IEnumerable<FailedPartitionAttempt> Attempts
}

/// <summary>
/// Gets or sets whether or not the failure is resolved.
/// Gets or sets whether the failure is resolved.
/// </summary>
public bool IsResolved { get; set; }

/// <summary>
/// Gets the last attempt for the failed partition.
/// </summary>
public FailedPartitionAttempt? LastAttempt => Attempts.LastOrDefault();
public FailedPartitionAttempt LastAttempt { get; private set; } = FailedPartitionAttempt.NoAttempt;

/// <summary>
/// Add an attempt to the failed partition.
Expand All @@ -53,5 +53,6 @@ public IEnumerable<FailedPartitionAttempt> Attempts
public void AddAttempt(FailedPartitionAttempt attempt)
{
Attempts = Attempts.Append(attempt);
LastAttempt = attempt;
}
}
5 changes: 5 additions & 0 deletions Source/Kernel/Concepts/Observation/FailedPartitionAttempt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace Cratis.Chronicle.Concepts.Observation;
/// </summary>
public class FailedPartitionAttempt
{
/// <summary>
/// Gets the empty <see cref="FailedPartitionAttempt"/>.
/// </summary>
public static FailedPartitionAttempt NoAttempt => new();

/// <summary>
/// Gets or sets when the attempt occurred.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions Source/Kernel/Concepts/Observation/FailedPartitionId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace Cratis.Chronicle.Concepts.Observation;
/// <param name="value">The inner value.</param>
public record FailedPartitionId(Guid value) : ConceptAs<Guid>(value)
{
public static implicit operator FailedPartitionId(Guid value) => new(value);

/// <summary>
/// Creates a new instance of the <see cref="FailedPartitionId"/> class with a new unique value.
/// </summary>
Expand Down
53 changes: 23 additions & 30 deletions Source/Kernel/Concepts/Observation/FailedPartitions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Cratis. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Diagnostics.CodeAnalysis;
using Cratis.Chronicle.Concepts.Events;
using Cratis.Chronicle.Concepts.Keys;

Expand All @@ -12,46 +13,44 @@
public class FailedPartitions
{
readonly List<FailedPartition> _resolvedPartitions = [];
List<FailedPartition> _partitions = [];
readonly Dictionary<Key, FailedPartition> _partitions = [];

/// <summary>
/// Gets or sets the failed partitions for the observer.
/// </summary>
public IEnumerable<FailedPartition> Partitions
{
get => _partitions;
set => _partitions = new(value);
get => _partitions.Values;
set
{
_partitions = failedPartitions.ToDictionary(_ => _.Partition, _ => _);

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

A readonly field cannot be assigned to (except in a constructor or init-only setter of the type in which the field is defined or a variable initializer)

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

The name 'failedPartitions' does not exist in the current context

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

A readonly field cannot be assigned to (except in a constructor or init-only setter of the type in which the field is defined or a variable initializer)

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

The name 'failedPartitions' does not exist in the current context

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

A readonly field cannot be assigned to (except in a constructor or init-only setter of the type in which the field is defined or a variable initializer)

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

The name 'failedPartitions' does not exist in the current context

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

A readonly field cannot be assigned to (except in a constructor or init-only setter of the type in which the field is defined or a variable initializer)

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

The name 'failedPartitions' does not exist in the current context

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / integration

A readonly field cannot be assigned to (except in a constructor or init-only setter of the type in which the field is defined or a variable initializer)

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / integration

The name 'failedPartitions' does not exist in the current context

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

A readonly field cannot be assigned to (except in a constructor or init-only setter of the type in which the field is defined or a variable initializer)

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

The name 'failedPartitions' does not exist in the current context

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

A readonly field cannot be assigned to (except in a constructor or init-only setter of the type in which the field is defined or a variable initializer)

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

The name 'failedPartitions' does not exist in the current context

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

A readonly field cannot be assigned to (except in a constructor or init-only setter of the type in which the field is defined or a variable initializer)

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

The name 'failedPartitions' does not exist in the current context

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

A readonly field cannot be assigned to (except in a constructor or init-only setter of the type in which the field is defined or a variable initializer)

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

The name 'failedPartitions' does not exist in the current context

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / integration

A readonly field cannot be assigned to (except in a constructor or init-only setter of the type in which the field is defined or a variable initializer)

Check failure on line 26 in Source/Kernel/Concepts/Observation/FailedPartitions.cs

View workflow job for this annotation

GitHub Actions / integration

The name 'failedPartitions' does not exist in the current context
}
}

/// <summary>
/// Gets or sets the resolved partitions for the observer.
/// Gets the resolved partitions for the observer.
/// </summary>
public IEnumerable<FailedPartition> ResolvedPartitions => _resolvedPartitions;

/// <summary>
/// Gets whether or not there are any failed partitions.
/// Gets a value indicating whether there are any failed partitions.
/// </summary>
public bool HasFailedPartitions => _partitions.Count > 0;

/// <summary>
/// Add a failed partition.
/// </summary>
/// <param name="failedPartition"><see cref="FailedPartition"/> to add.</param>
public void Add(FailedPartition failedPartition) => _partitions.Add(failedPartition);

/// <summary>
/// Check whether or not a partition is failed.
/// Check whether a partition is failed.
/// </summary>
/// <param name="partition">Partition to check.</param>
/// <returns>True if failed, false if not.</returns>
public bool IsFailed(Key partition) => _partitions.Exists(_ => _.Partition.Equals(partition));
public bool IsFailed(Key partition) => _partitions.ContainsKey(partition);

/// <summary>
/// Gets a failed partition by its partition identifier.
/// Try to get a failed partition by its partition identifier.
/// </summary>
/// <param name="partition">Partition to get.</param>
/// <returns>The failed partition.</returns>
public FailedPartition? Get(Key partition) => _partitions.Find(_ => _.Partition == partition);
/// <param name="failedPartition">The optional failed partition.</param>
/// <returns>True when failed partition exists, false if not.</returns>
public bool TryGet(Key partition, [NotNullWhen(true)]out FailedPartition? failedPartition) => _partitions.TryGetValue(partition, out failedPartition);

/// <summary>
/// Register an attempt for a partition.
Expand All @@ -67,19 +66,13 @@
IEnumerable<string> messages,
string stackTrace)
{
FailedPartition failure;
if (IsFailed(partition))
{
failure = Get(partition)!;
}
else
if (!TryGet(partition, out var failure))
{
failure = new FailedPartition
failure = new()
{
Id = FailedPartitionId.New(),
Partition = partition
};

Add(failure);
}

Expand All @@ -100,11 +93,11 @@
/// <param name="partition"><see cref="Key"/> to remove.</param>
public void Remove(Key partition)
{
var failedPartition = Get(partition);
if (failedPartition != null)
{
_resolvedPartitions.Add(failedPartition);
}
_partitions.RemoveAll(_ => _.Partition == partition);
if (!TryGet(partition, out var failedPartition)) return;

_resolvedPartitions.Add(failedPartition);
_partitions.Remove(partition);
}

void Add(FailedPartition failedPartition) => _partitions.Add(failedPartition.Partition, failedPartition);
}
2 changes: 0 additions & 2 deletions Source/Kernel/Concepts/Observation/ObserverInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace Cratis.Chronicle.Concepts.Observation;
/// <param name="NextEventSequenceNumber">The next event sequence number the observer will observe.</param>
/// <param name="LastHandledEventSequenceNumber">The event sequence number the observer last handled.</param>
/// <param name="RunningState">The running state of the observer.</param>
/// <param name="Handled">Number of events handled by the observer.</param>
/// <param name="FailedPartitions">Collection of <see cref="FailedPartition"/>.</param>
public record ObserverInformation(
ObserverId ObserverId,
Expand All @@ -26,5 +25,4 @@ public record ObserverInformation(
EventSequenceNumber NextEventSequenceNumber,
EventSequenceNumber LastHandledEventSequenceNumber,
ObserverRunningState RunningState,
EventCount Handled,
IEnumerable<FailedPartition> FailedPartitions);
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public interface IEventSequence : IGrainWithStringKey
/// <p>If no event is found, it will return <see cref="EventSequenceNumber.Unavailable"/>.</p>
/// </returns>
[AlwaysInterleave]
Task<EventSequenceNumber> GetNextSequenceNumberGreaterOrEqualThan(EventSequenceNumber sequenceNumber, IEnumerable<EventType>? eventTypes = null, EventSourceId? eventSourceId = null);
Task<EventSequenceNumber> GetNextSequenceNumberGreaterOrEqualTo(EventSequenceNumber sequenceNumber, IEnumerable<EventType>? eventTypes = null, EventSourceId? eventSourceId = null);

/// <summary>
/// Append a single event to the event store.
Expand Down
2 changes: 1 addition & 1 deletion Source/Kernel/Grains.Interfaces/Jobs/IJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public interface IJob : IGrainWithGuidCompoundKey
}

/// <summary>
/// Represents a job that typically runs as long running with <see cref="IJobStep{TRequest, TResult}"/>.
/// Represents a job that typically runs as long-running with <see cref="IJobStep{TRequest, TResult}"/>.
/// </summary>
/// <typeparam name="TRequest">Type of request object that gets passed to job.</typeparam>
public interface IJob<TRequest> : IJob
Expand Down
2 changes: 1 addition & 1 deletion Source/Kernel/Grains.Interfaces/Jobs/JobStepResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Cratis.Chronicle.Grains.Jobs;
public record JobStepResult(JobStepStatus Status, IEnumerable<string> Messages, string ExceptionStackTrace, object? Result = null)
{
/// <summary>
/// Gets whether or not the job step was successful.
/// Gets whether the job step was successful.
/// </summary>
public bool IsSuccess => Status == JobStepStatus.Succeeded;

Expand Down
28 changes: 15 additions & 13 deletions Source/Kernel/Grains.Interfaces/Observation/IObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Cratis.Chronicle.Grains.Observation;
public interface IObserver : IStateMachine<ObserverState>, IGrainWithStringKey
{
/// <summary>
/// Ensure the observers existence.
/// Ensure the observer existence.
/// </summary>
/// <returns>Awaitable task.</returns>
Task Ensure();
Expand All @@ -29,10 +29,9 @@ public interface IObserver : IStateMachine<ObserverState>, IGrainWithStringKey
/// <summary>
/// Set the handled stats for the observer.
/// </summary>
/// <param name="handled">Number of handled events.</param>
/// <param name="lastHandledEventSequenceNumber">The last handled event sequence number.</param>
/// <returns>Awaitable task.</returns>
Task SetHandledStats(EventCount handled, EventSequenceNumber lastHandledEventSequenceNumber);
Task SetHandledStats(EventSequenceNumber lastHandledEventSequenceNumber);

/// <summary>
/// Get the subscription for the observer.
Expand Down Expand Up @@ -99,8 +98,9 @@ Task Subscribe<TObserverSubscriber>(
/// Notify that the partition has been replayed.
/// </summary>
/// <param name="partition">The partition that has been replayed.</param>
/// <param name="lastHandledEventSequenceNumber">The event sequence number of the last event that as handled in the catchup.</param>
/// <returns>Awaitable task.</returns>
Task PartitionReplayed(Key partition);
Task PartitionReplayed(Key partition, EventSequenceNumber lastHandledEventSequenceNumber);

/// <summary>
/// Notify that the partition has failed.
Expand All @@ -116,15 +116,24 @@ Task Subscribe<TObserverSubscriber>(
/// Notify that the partition has recovered.
/// </summary>
/// <param name="partition">The partition that has recovered.</param>
/// <param name="lastHandledEventSequenceNumber">The event sequence number of the last event that as handled in the catchup.</param>
/// <returns>Awaitable task.</returns>
Task FailedPartitionRecovered(Key partition);
Task FailedPartitionRecovered(Key partition, EventSequenceNumber lastHandledEventSequenceNumber);

/// <summary>
/// Notify that the partition was caught.
/// </summary>
/// <param name="partition">The partition that has caught up.</param>
/// <param name="lastHandledEventSequenceNumber">The event sequence number of the last event that as handled in the catchup.</param>
/// <returns>Awaitable task.</returns>
Task PartitionCaughtUp(Key partition, EventSequenceNumber lastHandledEventSequenceNumber);

/// <summary>
/// Attempt to recover a failed partition.
/// </summary>
/// <param name="partition">The partition that is failed.</param>
/// <returns>Awaitable task.</returns>
Task TryRecoverFailedPartition(Key partition);
Task TryStartRecoverJobForFailedPartition(Key partition);

/// <summary>
/// Attempt to recover all failed partitions.
Expand All @@ -139,11 +148,4 @@ Task Subscribe<TObserverSubscriber>(
/// <param name="events">Collection of <see cref="AppendedEvent"/>.</param>
/// <returns>Awaitable task.</returns>
Task Handle(Key partition, IEnumerable<AppendedEvent> events);

/// <summary>
/// Report a count of events that has been handled.
/// </summary>
/// <param name="count"><see cref="EventCount"/> to increase the handled count with.</param>
/// <returns>Awaitable task.</returns>
Task ReportHandledEvents(EventCount count);
}
16 changes: 0 additions & 16 deletions Source/Kernel/Grains.Interfaces/Observation/IObservers.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Cratis. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Cratis.Chronicle.Concepts.Events;
using Cratis.Chronicle.Concepts.Keys;
using Cratis.Chronicle.Concepts.Observation;
namespace Cratis.Chronicle.Grains.Observation.Jobs;

/// <summary>
/// Represents the request for a <see cref="ICatchUpObserverPartition"/>.
/// </summary>
/// <param name="ObserverId">The identifier of the observer to replay.</param>
/// <param name="ObserverKey">The additional <see cref="ObserverKey"/> for the observer to catch up.</param>
/// <param name="ObserverSubscription">The <see cref="ObserverSubscription"/> for the observer.</param>
/// <param name="Key"><see cref="Key">Partition</see> to retry.</param>
/// <param name="FromSequenceNumber">From <see cref="EventSequenceNumber"/> to catch up from.</param>
/// <param name="EventTypes">The event types.</param>
public record CatchUpObserverPartitionRequest(
ObserverId ObserverId,
ObserverKey ObserverKey,
ObserverSubscription ObserverSubscription,
Key Key,
EventSequenceNumber FromSequenceNumber,
IEnumerable<EventType> EventTypes);

This file was deleted.

Loading
Loading