Mark a Cratis Chronicle model-bound projection as not rewindable
[NotRewindable] sets IsRewindable to false on a Cratis Chronicle model-bound projection definition. Use it to declare that the projection is intended to move forward only.
In C#, apply the attribute to the read model type:
using Cratis.Chronicle.Events;using Cratis.Chronicle.Keys;using Cratis.Chronicle.Projections.ModelBound;
[EventType]public record MbNotRewindableAuditEvent(string Message, DateTimeOffset OccurredAt);
[NotRewindable]public record MbNotRewindableAuditLog( [Key] Guid Id,
[SetFrom<MbNotRewindableAuditEvent>(nameof(MbNotRewindableAuditEvent.Message))] string Message,
[SetFrom<MbNotRewindableAuditEvent>(nameof(MbNotRewindableAuditEvent.OccurredAt))] DateTimeOffset Timestamp);import io.cratis.chronicle.events.EventTypeimport io.cratis.chronicle.projections.FromEventimport io.cratis.chronicle.projections.NotRewindableimport io.cratis.chronicle.projections.SetFromimport io.cratis.chronicle.readModels.ReadModel
@EventTypedata class MbNotRewindableAuditEvent(val message: String, val occurredAt: String)
@ReadModel@FromEvent(MbNotRewindableAuditEvent::class)@NotRewindabledata class MbNotRewindableAuditLog( @SetFrom("message", MbNotRewindableAuditEvent::class) val message: String = "",
@SetFrom("occurredAt", MbNotRewindableAuditEvent::class) val timestamp: String = "")import io.cratis.chronicle.events.EventType;import io.cratis.chronicle.projections.FromEvent;import io.cratis.chronicle.projections.NotRewindable;import io.cratis.chronicle.projections.SetFrom;import io.cratis.chronicle.readModels.ReadModel;
@EventTyperecord MbNotRewindableAuditEvent(String message, String occurredAt) {}
@ReadModel@FromEvent(eventType = MbNotRewindableAuditEvent.class)@NotRewindableclass MbNotRewindableAuditLog { @SetFrom(propertyPath = "message", eventType = MbNotRewindableAuditEvent.class) public String message = "";
@SetFrom(propertyPath = "occurredAt", eventType = MbNotRewindableAuditEvent.class) public String timestamp = "";}defmodule MyApp.Events.MbNotRewindableAuditEvent do use Chronicle.Events.EventType, id: "mb-not-rewindable-audit-event"
defstruct message: "", occurred_at: ""end
defmodule MyApp.ReadModels.MbNotRewindableAuditLog do use Chronicle.ReadModels.ReadModel, not_rewindable: true
defstruct id: "", message: "", timestamp: ""
from MyApp.Events.MbNotRewindableAuditEvent, set: [id: :event_source_id, message: :message, timestamp: :occurred_at]endimport { eventType, Guid, notRewindable, setFrom } from '@cratis/chronicle';
@eventType()export class MbNotRewindableAuditEvent { message = ''; occurredAt = new Date();}
@notRewindableexport class MbNotRewindableAuditLog { id: Guid = Guid.empty;
@setFrom(MbNotRewindableAuditEvent, 'message') message = '';
@setFrom(MbNotRewindableAuditEvent, 'occurredAt') timestamp = new Date();}The example marks MbNotRewindableAuditLog as not rewindable while keeping its event-to-property mappings unchanged. Without the attribute, the model-bound builder sets IsRewindable to true.
This projection setting is separate from observer replayability. It does not configure how a reactor handles historical events; see Observers for replay policy and Reactor replay handlers for replay-specific work.