Skip to content

Commit

Permalink
add example for connection params and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinceveve committed Jul 10, 2020
1 parent 2f7bdfe commit a11f30c
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion examples/src/heroes/event-store-heroes.module.ts
Expand Up @@ -10,6 +10,7 @@ import { EventStoreCqrsModule, IEventStoreEventOptions } from '../../../src';
import { HealthController } from './health.controller';
import { TerminusModule } from '@nestjs/terminus';
import { LoggerModule } from 'nestjs-pino-stackdriver/dist';
import * as util from 'util';

@Module({
imports: [
Expand All @@ -29,8 +30,42 @@ import { LoggerModule } from 'nestjs-pino-stackdriver/dist';
port: +process.env.EVENTSTORE_HTTP_PORT || 22113,
},
tcpConnectionName: 'connection-hero-event-handler-and-saga',
options: {
log: {
debug: (str, ...args) => {
Logger.warn(util.format(str, ...args), 'EventStoreCore');
},
info: (str, ...args) => {
Logger.log(util.format(str, ...args), 'EventStoreCore');
},
error: (str, ...args) => {
Logger.log(util.format(str, ...args), 'EventStoreCore');
},
},
// Buffer events if remote is slow or not available
maxQueueSize: 100_000,
maxRetries: 10_000,
operationTimeout: 5_000,
operationTimeoutCheckPeriod: 1_000,
// Fail fast on connect
clientConnectionTimeout: 2_000,
failOnNoServerResponse: true,
// Try to reconnect every 10s for 30mn
maxReconnections: 200,
reconnectionDelay: 10_000,
// Production heartbeat
heartbeatInterval: 10_000,
heartbeatTimeout: 3_000,
},
onTcpDisconnected: () => {
Logger.error(
`Connection to eventstore lost`,
undefined,
'EventStoreCore',
);
//process.exit(137);
},
onTcpConnected: () => {},
onTcpDisconnected: () => {},
},
{
eventMapper: (data, options: IEventStoreEventOptions) => {
Expand Down

0 comments on commit a11f30c

Please sign in to comment.