Skip to content

CHR0055: Unknown event stream on typed event source filter

[FromEventSource<TSource>("stream")] makes a reactor or reducer handle only the events of one stream of an event source definition. The stream name must be one that TSource declares with [EventStream]. If it is not, the client throws EventStreamDoesNotBelongToEventSource when it registers the observer, so the application fails at start up.

CHR0055 reports the same mistake when you compile. The names are compared exactly, including the casing.

Error

using Cratis.Chronicle.Events;
using Cratis.Chronicle.EventSources;
using Cratis.Chronicle.Reactors;
[EventType]
public record Chr0055PaymentReceived(decimal Amount);
[EventSource("Order")]
[EventStream("Payments")]
public class Chr0055OrderEventSource : IEventSource;
// Error CHR0055: Chr0055OrderEventSource does not declare an event stream named "Payment".
[FromEventSource<Chr0055OrderEventSource>("Payment")]
public class Chr0055PaymentReactor : IReactor
{
public Task Received(Chr0055PaymentReceived @event, EventContext context) => Task.CompletedTask;
}

View C# snippet source on GitHub

Use the name of a declared stream, or declare the stream on the definition.

using Cratis.Chronicle.Events;
using Cratis.Chronicle.EventSources;
using Cratis.Chronicle.Reactors;
[EventType]
public record Chr0055FixPaymentReceived(decimal Amount);
[EventSource("Order")]
[EventStream("Payments")]
public class Chr0055FixOrderEventSource : IEventSource;
// The stream name matches the declared stream exactly.
[FromEventSource<Chr0055FixOrderEventSource>("Payments")]
public class Chr0055FixPaymentReactor : IReactor
{
public Task Received(Chr0055FixPaymentReceived @event, EventContext context) => Task.CompletedTask;
}

View C# snippet source on GitHub

The stream name is a string in an attribute argument, so the compiler cannot check it. Without the rule a typo ships and surfaces as a crash at start up. The rule moves the failure to the line that has the typo.