CHR0004: Reactor method signature must match allowed signatures
Rule Description
Section titled “Rule Description”Methods in reactor classes must follow one of the allowed signatures for event handling. This ensures proper integration with Chronicle’s reactor infrastructure.
Severity
Section titled “Severity”Warning
Allowed Signatures
Section titled “Allowed Signatures”Event handler methods in reactors must have one of the following signatures:
// Async with event onlyTask MethodName(TEvent @event)
// Async with event and contextTask MethodName(TEvent @event, EventContext context)
// Synchronous with event onlyvoid MethodName(TEvent @event)
// Synchronous with event and contextvoid MethodName(TEvent @event, EventContext context)Where TEvent is a type marked with [EventType].
Example
Section titled “Example”Violation
Section titled “Violation”public class OrderReactor : IReactor{ // CHR0004: Invalid signature - returns Task<bool> instead of Task public async Task<bool> OrderCreated(OrderCreated @event) { // Process event return true; }
// CHR0004: Invalid signature - third parameter not allowed public async Task OrderUpdated(OrderUpdated @event, EventContext context, string extraParam) { // Process event }}public class OrderReactor : IReactor{ // Valid signature public async Task OrderCreated(OrderCreated @event) { // Process event }
// Valid signature with context public async Task OrderUpdated(OrderUpdated @event, EventContext context) { // Process event }
// Valid synchronous signature public void OrderShipped(OrderShipped @event) { // Process event }}Why This Rule Exists
Section titled “Why This Rule Exists”Reactors are a core pattern in Chronicle for handling side effects when events occur. Standardized method signatures ensure:
- Predictable reactor behavior
- Proper infrastructure integration
- Clear code patterns across the codebase
- Reliable event handling