-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #38 Auto discover masters when using sentinel #31
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c3fa57d
auto discover masters when using sentinel
gkorland 80f3f7a
Merge branch 'main' into sentinel
gkorland 2da8440
add command SENTINEL_MASTERS
gkorland 4ad80e4
automatic reconnet on failover
gkorland 34c312d
reconnect using sentinel on disconnection
gkorland b7d20d0
auto discover masters when using sentinel
gkorland 4dcf5a1
add command SENTINEL_MASTERS
gkorland 5fe1145
automatic reconnet on failover
gkorland a70fcde
reconnect using sentinel on disconnection
gkorland 74ab9c3
Merge branch 'sentinel' of github.com:FalkorDB/falkordb-ts into sentinel
gkorland 817dfee
update depts
gkorland 6fff643
update deps
gkorland b283467
Merge branch 'main' into sentinel
gkorland 5a9cbcd
Merge branch 'main' into sentinel
gkorland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { FalkorDB } from 'falkordb'; | ||
|
||
const db = await FalkorDB.connect({ | ||
// username: 'myUsername', | ||
// password: 'myPassword', | ||
socket: { | ||
host: 'localhost', | ||
port: 26379 | ||
} | ||
}) | ||
db.on('error', console.error) | ||
|
||
console.log('Connected to FalkorDB') | ||
|
||
const graph = db.selectGraph('myGraph') | ||
const result = await graph.query('MATCH (n) RETURN n') | ||
|
||
console.log(result) | ||
|
||
console.log(await db.list()) | ||
console.log(await db.info()) | ||
console.log(await db.connection.info()) | ||
|
||
db.close() |
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,7 @@ | ||
export const IS_READ_ONLY = true; | ||
|
||
export function transformArguments(dbname: string): Array<string> { | ||
return ['SENTINEL', 'MASTER', dbname]; | ||
} | ||
|
||
export declare function transformReply(): Array<string>; |
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,7 @@ | ||
export const IS_READ_ONLY = true; | ||
|
||
export function transformArguments(): Array<string> { | ||
return ['SENTINEL', 'MASTERS']; | ||
} | ||
|
||
export declare function transformReply(): Array<Array<string>>; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
connectServer
method is a significant addition and is central to the new functionality for connecting to Redis through Sentinel. Here are a few observations and suggestions:...redisOption.socket
) is clean and effective..on('error', ...)
callback is robust, including reconnection attempts and error forwarding.However, there are a couple of areas that could be improved:
details
array will always have at least one element (details[0]
). It would be safer to add a check to ensure thatdetails
is not empty before accessing its elements.connectServer
keeps failing. Consider implementing a maximum retry limit or using a more sophisticated backoff strategy.Committable suggestion