-
Notifications
You must be signed in to change notification settings - Fork 2
es cqrs.Class.ReplayService
Sclable CI edited this page Oct 7, 2024
·
7 revisions
@sclable/nestjs-libs / es-cqrs / ReplayService
This service is used to replay events from the event store
Can be run in a separate script.
Example: replay.ts
@EventHandler(ReplayFinished)
class ReplayFinishedHandler implements IEventHandler<ReplayFinished> {
public handle() {
console.log('Replay finished')
}
}
@Module({
imports: [
ESCQRSModule.forRoot({...}),
FeatureModule1,
FeatureModule2,
],
})
class ResetAndReplayModule {}
async function run() {
const app = await NestFactory.create(ResetAndReplayModule)
await app.init()
const replayService = app.get<ReplayService>(ReplayService)
await replayService.replay()
await app.close()
}
run()
new ReplayService(
eventStore
,eventBus
,logger
,options
):ReplayService
• eventStore: EventStoreProvider
• eventBus: EventBus
• logger: Logger
• options: EventStoreOptions
packages/es-cqrs/src/event-store/replay.service.ts:57
replay(
replayOptions
?):Promise
<number
>
• replayOptions?: ReplayOptions
replay options
Promise
<number
>
number of events replayed