From a042a84ec44c25fa6c4d01798ef9455d68a2d908 Mon Sep 17 00:00:00 2001 From: Andy Payne Date: Wed, 26 Jul 2023 15:07:23 +0100 Subject: [PATCH] feat: update redis cluster constructor add required options to connect to redis cluster --- lib/redis/index.js | 40 +++++++++------ site.config.js | 120 ++++++++++++++++++++++++--------------------- 2 files changed, 89 insertions(+), 71 deletions(-) diff --git a/lib/redis/index.js b/lib/redis/index.js index d0d503c1..1e288700 100644 --- a/lib/redis/index.js +++ b/lib/redis/index.js @@ -46,29 +46,40 @@ function getRedisConfiguration() { export async function createRedisInstance(config = getRedisConfiguration()) { try { const options = { - host: config.host, - lazyConnect: true, - showFriendlyErrorStack: true, - enableAutoPipelining: true, - maxRetriesPerRequest: 0, - retryStrategy: times => { - if (times > 3) { - throw new Error(`[Redis] Could not connect after ${times} attempts`); + enableReadyCheck: true, + scaleReads: "all", + slotsRefreshTimeout: 5000, + redisOptions: { + host: config.host, + lazyConnect: true, + showFriendlyErrorStack: true, + enableAutoPipelining: true, + maxRetriesPerRequest: 0, + retryStrategy: times => { + if (times > 3) { + throw new Error(`[Redis] Could not connect after ${times} attempts`); + } + + return Math.min(times * 200, 1000); } - - return Math.min(times * 200, 1000); }, - }; + } if (config.port) { - options.port = config.port; + options.redisOptions.port = config.port; } if (config.password) { - options.password = config.password; + options.redisOptions.password = config.password; } - const redis = new Redis.Cluster(options); + const redis = new Redis.Cluster([ + { + host: config.host, + port: config.port + }], + options + ); redis.on('error', error => { console.warn('[Redis] Error connecting', error); @@ -111,6 +122,7 @@ export async function cacheRead(key) { if (!redisInstance) { redisInstance = await createRedisInstance(); } + console.log(redisInstance) const value = await redisInstance.get(key); if (!value) return null; const parsedValue = JSON.parse(value); diff --git a/site.config.js b/site.config.js index 59569581..2f62e72f 100644 --- a/site.config.js +++ b/site.config.js @@ -3,77 +3,83 @@ export const siteConfig = { company: `airwalkreply.com`, tagline: `technology, done right`, etherpad: { - url: 'https://pad.airview.airwalkconsulting.io' + url: "https://pad.airview.airwalkconsulting.io", }, content: { services: { - source: 'github', // The source of the content - repo: 'airwalk_patterns', // The name of the repo - owner: 'airwalk-digital', // The owner of the repo - branch: '1-rob-ellison', - path: 'services', // the base path for the content - reference: 'service', // how the collection is referred to in frontmatter links - collections: ['knowledge', 'designs'] - + source: "github", // The source of the content + repo: "airview-demo-content", // The name of the repo + owner: "airwalk-digital", // The owner of the repo + branch: "main", + path: "services", // the base path for the content + reference: "service", // how the collection is referred to in frontmatter links + collections: ["knowledge", "designs"], }, providers: { - source: 'github', // The source of the content - repo: 'airwalk_patterns', // The name of the repo - owner: 'airwalk-digital', // The owner of the repo - branch: '1-rob-ellison', - path: 'providers', // the base path for the content - reference: 'provider', // how the collection is referred to in frontmatter links - collections: ['services'] + source: "github", // The source of the content + repo: "airview-demo-content", // The name of the repo + owner: "airwalk-digital", // The owner of the repo + branch: "main", + path: "providers", // the base path for the content + reference: "provider", // how the collection is referred to in frontmatter links + collections: ["services"], }, solutions: { - source: 'github', // The source of the content - repo: 'airwalk_patterns', // The name of the repo - owner: 'airwalk-digital', // The owner of the repo - branch: '1-rob-ellison', - path: 'solutions', // the base path for the content - reference: 'solution', // how the collection is referred to in frontmatter links - collections: ['knowledge', 'designs'] - + source: "github", // The source of the content + repo: "airview-demo-content", // The name of the repo + owner: "airwalk-digital", // The owner of the repo + branch: "main", + path: "solutions", // the base path for the content + reference: "solution", // how the collection is referred to in frontmatter links + collections: ["knowledge", "designs"], }, knowledge: { - source: 'github', // The source of the content - repo: 'airwalk_patterns', // The name of the repo - owner: 'airwalk-digital', // The owner of the repo - branch: 'main', - path: 'knowledge', // the base path for the content - reference: 'knowledge', // how the collection is referred to in frontmatter links + source: "github", // The source of the content + repo: "airview-demo-content", // The name of the repo + owner: "airwalk-digital", // The owner of the repo + branch: "main", + path: "knowledge", // the base path for the content + reference: "knowledge", // how the collection is referred to in frontmatter links }, designs: { - source: 'github', // The source of the content - repo: 'airwalk_patterns', // The name of the repo - owner: 'airwalk-digital', // The owner of the repo - branch: 'main', - path: 'designs', // the base path for the content - reference: 'design', // how the collection is referred to in frontmatter links - collections: ['knowledge'] + source: "github", // The source of the content + repo: "airview-demo-content", // The name of the repo + owner: "airwalk-digital", // The owner of the repo + branch: "main", + path: "designs", // the base path for the content + reference: "design", // how the collection is referred to in frontmatter links + collections: ["knowledge"], }, customers: { - source: 'github', // The source of the content - repo: 'airwalk_patterns', // The name of the repo - owner: 'airwalk-digital', // The owner of the repo - branch: 'main', - path: 'customers', // the base path for the content - reference: 'customer', // how the collection is referred to in frontmatter links - collections: ['knowledge', 'projects'] + source: "github", // The source of the content + repo: "airview-demo-content", // The name of the repo + owner: "airwalk-digital", // The owner of the repo + branch: "main", + path: "customers", // the base path for the content + reference: "customer", // how the collection is referred to in frontmatter links + collections: ["knowledge", "projects"], }, projects: { - source: 'github', // The source of the content - repo: 'airwalk_patterns', // The name of the repo - owner: 'airwalk-digital', // The owner of the repo - branch: 'main', - path: 'projects', // the base path for the content - reference: 'project', // how the collection is referred to in frontmatter links - collections: ['knowledge'] + source: "github", // The source of the content + repo: "airview-demo-content", // The name of the repo + owner: "airwalk-digital", // The owner of the repo + branch: "main", + path: "projects", // the base path for the content + reference: "project", // how the collection is referred to in frontmatter links + collections: ["knowledge"], }, - applications: { source: 'static'}, - frameworks: { source: 'static'} - } - -} + products: { + source: "github", // The source of the content + repo: "airview-demo-content", // The name of the repo + owner: "airwalk-digital", // The owner of the repo + branch: "main", + path: "products", // the base path for the content + reference: "product", // how the collection is referred to in frontmatter links + collections: ["knowledge", "designs"], + }, + applications: { source: "static" }, + frameworks: { source: "static" }, + }, +}; -export default siteConfig +export default siteConfig;