Skip to content

es cqrs.Class.ReplayService

Sclable CI edited this page Oct 7, 2024 · 7 revisions

@sclable/nestjs-libs / es-cqrs / ReplayService

Class: 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()

Constructors

new ReplayService()

new ReplayService(eventStore, eventBus, logger, options): ReplayService

Parameters

eventStore: EventStoreProvider

eventBus: EventBus

logger: Logger

options: EventStoreOptions

Returns

ReplayService

Defined in

packages/es-cqrs/src/event-store/replay.service.ts:57

Methods

replay()

replay(replayOptions?): Promise<number>

Parameters

replayOptions?: ReplayOptions

replay options

Returns

Promise<number>

number of events replayed

Defined in

packages/es-cqrs/src/event-store/replay.service.ts:68

Clone this wiki locally