Skip to content

es cqrs.ReplayService

Sclable CI edited this page Sep 11, 2024 · 198 revisions

Class: ReplayService

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

Table of contents

Constructors

Properties

Methods

Constructors

constructor

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

Parameters

Name Type
eventStore EventStoreProvider
eventBus EventBus
logger Logger
options EventStoreOptions

Returns

ReplayService

Defined in

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

Properties

eventBus

Private Readonly eventBus: EventBus

Defined in

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


eventStore

Private Readonly eventStore: EventStoreProvider

Defined in

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


logger

Private Readonly logger: Logger

Defined in

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


options

Private Readonly options: EventStoreOptions

Defined in

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

Methods

replay

replay(replayOptions?): Promise<number>

Parameters

Name Type Description
replayOptions? ReplayOptions replay options

Returns

Promise<number>

Retuns

number of events replayed

Defined in

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

Clone this wiki locally