Skip to content

Commit

Permalink
Merge pull request #4690 from novuhq/azure-cluster-connect
Browse files Browse the repository at this point in the history
feat: add support for tls servername for azure redis
  • Loading branch information
Cliftonz authored Oct 29, 2023
2 parents 2e97e62 + 4499975 commit 06843bf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export const getElasticacheClusterProviderConfig =
keepAlive: process.env.REDIS_CLUSTER_KEEP_ALIVE,
family: process.env.REDIS_CLUSTER_FAMILY,
keyPrefix: process.env.REDIS_CLUSTER_KEY_PREFIX,
tls: process.env.REDIS_CLUSTER_TLS as ConnectionOptions,
tls: (process.env.ELASTICACHE_CLUSTER_SERVICE_TLS as ConnectionOptions)
? { servername: process.env.ELASTICACHE_CLUSTER_SERVICE_HOST }
: {},
};

const host = redisClusterConfig.host;
Expand Down Expand Up @@ -82,21 +84,23 @@ export const getElasticacheClusterProviderConfig =
keepAlive,
keyPrefix,
ttl,
tls: redisClusterConfig.tls,
};
};

export const getElasticacheCluster = (
enableAutoPipelining?: boolean
): Cluster | undefined => {
const { instances } = getElasticacheClusterProviderConfig();
const { instances, password, tls } = getElasticacheClusterProviderConfig();

const options: ClusterOptions = {
dnsLookup: (address, callback) => callback(null, address),
enableAutoPipelining: enableAutoPipelining ?? false,
enableOfflineQueue: false,
enableReadyCheck: true,
redisOptions: {
tls: {},
tls,
...(password && { password }),
connectTimeout: 10000,
},
scaleReads: 'slave',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export const getMemoryDbClusterProviderConfig =
keepAlive: process.env.MEMORY_DB_CLUSTER_SERVICE_KEEP_ALIVE,
family: process.env.MEMORY_DB_CLUSTER_SERVICE_FAMILY,
keyPrefix: process.env.MEMORY_DB_CLUSTER_SERVICE_KEY_PREFIX,
tls: process.env.MEMORY_DB_CLUSTER_SERVICE_TLS as ConnectionOptions,
tls: (process.env.MEMORY_DB_CLUSTER_SERVICE_TLS as ConnectionOptions)
? { servername: process.env.MEMORY_DB_CLUSTER_SERVICE_HOST }
: {},
};

const host = redisClusterConfig.host;
Expand Down Expand Up @@ -87,20 +89,22 @@ export const getMemoryDbClusterProviderConfig =
keepAlive,
keyPrefix,
ttl,
tls: redisClusterConfig.tls,
};
};

export const getMemoryDbCluster = (
enableAutoPipelining?: boolean
): Cluster | undefined => {
const { instances, password, username } = getMemoryDbClusterProviderConfig();
const { instances, password, username, tls } =
getMemoryDbClusterProviderConfig();

const options: ClusterOptions = {
dnsLookup: (address, callback) => callback(null, address),
enableAutoPipelining: enableAutoPipelining ?? false,
enableOfflineQueue: false,
redisOptions: {
tls: {},
tls,
connectTimeout: 10000,
...(password && { password }),
...(username && { username }),
Expand Down

0 comments on commit 06843bf

Please sign in to comment.