-
-
Notifications
You must be signed in to change notification settings - Fork 18
Backend redis improvements #1450
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,7 @@ import { ValidateTableSettingsDS } from '../shared/data-structures/validate-tabl | |||||||||
| import { FilterCriteriaEnum } from '../shared/enums/filter-criteria.enum.js'; | ||||||||||
| import { IDataAccessObject } from '../shared/interfaces/data-access-object.interface.js'; | ||||||||||
| import { BasicDataAccessObject } from './basic-data-access-object.js'; | ||||||||||
| import { isRedisConnectionUrl } from '../shared/create-data-access-object.js'; | ||||||||||
|
|
||||||||||
| export class DataAccessObjectRedis extends BasicDataAccessObject implements IDataAccessObject { | ||||||||||
| constructor(connection: ConnectionParams) { | ||||||||||
|
|
@@ -857,6 +858,7 @@ export class DataAccessObjectRedis extends BasicDataAccessObject implements IDat | |||||||||
| try { | ||||||||||
| if (!client) { | ||||||||||
| const shouldUseTLS = this.connection.ssl !== false; | ||||||||||
| const isConnectionUrl = isRedisConnectionUrl(this.connection.host); | ||||||||||
|
|
||||||||||
| const socketConfig: any = { | ||||||||||
| host: this.connection.host, | ||||||||||
|
|
@@ -880,9 +882,10 @@ export class DataAccessObjectRedis extends BasicDataAccessObject implements IDat | |||||||||
| } | ||||||||||
|
|
||||||||||
| client = createClient({ | ||||||||||
| socket: socketConfig, | ||||||||||
| password: this.connection.password || undefined, | ||||||||||
| username: this.connection.username || undefined, | ||||||||||
| socket: isConnectionUrl ? undefined : socketConfig, | ||||||||||
| url: isConnectionUrl ? this.connection.host : undefined, | ||||||||||
| password: isConnectionUrl ? undefined : this.connection.password ? this.connection.password : undefined, | ||||||||||
| username: isConnectionUrl ? undefined : this.connection.username ? this.connection.username : undefined, | ||||||||||
|
Comment on lines
+887
to
+888
|
||||||||||
| password: isConnectionUrl ? undefined : this.connection.password ? this.connection.password : undefined, | |
| username: isConnectionUrl ? undefined : this.connection.username ? this.connection.username : undefined, | |
| password: isConnectionUrl ? undefined : this.connection.password, | |
| username: isConnectionUrl ? undefined : this.connection.username, |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -96,7 +96,7 @@ function buildConnectionParams(connectionParams: IUnknownConnectionParams): Conn | |||||||||||
|
|
||||||||||||
| const sqlAndMongoRequiredKeys = ['type', 'host', 'port', 'username', 'password', 'database']; | ||||||||||||
| const elasticAndDynamoAndRedisRequiredKeys = ['host', 'username', 'password']; | ||||||||||||
| const redisRequiredKeys = ['host', 'port', 'password']; | ||||||||||||
| const redisRequiredKeys = !isRedisConnectionUrl(connectionParams.host) ? ['host', 'port', 'password'] : ['host']; | ||||||||||||
|
|
||||||||||||
| switch (connectionParams.type) { | ||||||||||||
| case ConnectionTypesEnum.postgres: | ||||||||||||
|
|
@@ -155,3 +155,8 @@ function buildConnectionParams(connectionParams: IUnknownConnectionParams): Conn | |||||||||||
| }; | ||||||||||||
| return connection; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| export function isRedisConnectionUrl(host: string): boolean { | ||||||||||||
|
||||||||||||
| export function isRedisConnectionUrl(host: string): boolean { | |
| export function isRedisConnectionUrl(host: string): boolean { | |
| if (!host) { | |
| return false; | |
| } |
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.
[nitpick] When a Redis connection URL is detected, the validation returns early without validating the
portfield. However, the subsequent code (lines 740-742) still expectsportto be a valid number. This could lead to issues if someone provides a Redis URL but also provides an invalid port value.Consider either:
Or move the port validation before the early return.