-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: race condition around heartbeating timeout after re-election
- Loading branch information
1 parent
721a63d
commit 998bbc1
Showing
8 changed files
with
109 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './types' | ||
export * from './LeadshipSvc/LeadershipSvc' | ||
export * from './LeadershipSvc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const testValues = { | ||
getInteger: (key: string, defaultValue?: number) => { | ||
const v = sessionStorage.getItem(key) | ||
console.log('getInteger', key, v) | ||
try { | ||
const n = v ? parseInt(v) : undefined | ||
return Number.isInteger(n) ? n : defaultValue | ||
} catch { | ||
return defaultValue | ||
} | ||
}, | ||
getString: (key: string, defaultValue?: string) => { | ||
const v = sessionStorage.getItem(key) | ||
return v ?? defaultValue | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
import { bind } from '@react-rxjs/core' | ||
import { LeadershipSvc } from '@tabrx/leader' | ||
import { LeadershipOptions, LeadershipSvc } from '@tabrx/leader' | ||
import { testValues } from './testValues' | ||
|
||
export const leadershipSvc = new LeadershipSvc({ | ||
const options: Partial<LeadershipOptions> = { | ||
channelName: testValues.getString('test-channelName', 'tabrx-leader'), | ||
electionChannelName: testValues.getString('test-channelName', 'tabrx-leader'), | ||
logger: { | ||
debug: console.debug, | ||
info: console.info, | ||
}, | ||
heartbeatInterval: 1000, | ||
heartbeatTimeout: 900, | ||
}) | ||
startupTimeout: testValues.getInteger('test-startupTimeout'), | ||
electionTimeoutMin: testValues.getInteger('test-electionTimeoutMin'), | ||
} | ||
|
||
console.log('options.a', JSON.stringify(options)) | ||
|
||
export const leadershipSvc = new LeadershipSvc(options) | ||
leadershipSvc.start() | ||
|
||
export const [useLeader, leader$] = bind(leadershipSvc.leader$, undefined) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters