Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
make _changes polling configurable by env
Browse files Browse the repository at this point in the history
  • Loading branch information
sleidig committed Feb 16, 2024
1 parent 7a75036 commit 6f8ad0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ DATABASE_USER=admin
DATABASE_PASSWORD=admin
QUERY_URL=http://127.0.0.1:4984
SCHEMA_CONFIG_ID=_design/sqlite:config
REPORT_DATABASE_URL=http://127.0.0.1:5984
REPORT_DATABASE_NAME=app

CHANGES_POLL_INTERVAL=60000
8 changes: 7 additions & 1 deletion src/report-changes/storage/couchdb-changes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class CouchdbChangesService extends DatabaseChangesService {
private databasePassword: string =
this.configService.getOrThrow('DATABASE_PASSWORD');

private changesPollInterval: number = Number(
this.configService.getOrThrow('CHANGES_POLL_INTERVAL'),
);

private authHeaderValue: string;

constructor(
Expand All @@ -65,7 +69,9 @@ export class CouchdbChangesService extends DatabaseChangesService {
filter((res) => res.last_seq !== lastSeq),
tap((res) => (lastSeq = res.last_seq)),
// poll regularly to get latest changes
repeat({ delay: 10000 }),
repeat({
delay: this.changesPollInterval,
}),
tap((res) => console.log('incoming couchdb changes', res)),
);

Expand Down

0 comments on commit 6f8ad0a

Please sign in to comment.