From 24f2588e43b1c1dec49fc15e4036495e7bac95dc Mon Sep 17 00:00:00 2001 From: Roman Kalyakin Date: Thu, 2 Jan 2025 16:52:41 +0100 Subject: [PATCH] updated examples --- config/default.example.json | 44 +++++++++-------- config/default.json | 83 ++++++++++---------------------- src/cache.ts | 2 +- src/models/generated/common.d.ts | 6 +-- src/redis.ts | 14 +++--- src/schema/common/config.json | 2 - 6 files changed, 58 insertions(+), 93 deletions(-) diff --git a/config/default.example.json b/config/default.example.json index 612dab72..667422c1 100644 --- a/config/default.example.json +++ b/config/default.example.json @@ -11,7 +11,7 @@ "max": 50 }, "redis": { - "enable": false + "host": "localhost" }, "rateLimiter": { "enabled": false, @@ -91,23 +91,29 @@ "users": "auth_user" } }, - "solr": { - "host": "localhost", - "port": 8984, - "auth": { - "user": "", - "pass": "*****" - }, - "search": { - "endpoint": "https://.../select" - }, - "mentions": { - "endpoint": "https://.../select", - "suggest": "https://.../suggest" - }, - "topics": { - "endpoint": "https://.../select", - "suggest": "https://.../suggest" - } + "solrConfiguration": { + "servers": [ + { + "id": "default", + "baseUrl": "https://localhost:8983/solr", + "auth": { + "read": { "username": "reader", "password": "..." }, + "write": { "username": "writer", "password": "..." } + } + } + ], + "namespaces": [ + { "namespaceId": "search", "serverId": "default", "index": "search_index" }, + { "namespaceId": "mentions", "serverId": "default", "index": "mentions_index" }, + { "namespaceId": "topics", "serverId": "default", "index": "topics_index" }, + { "namespaceId": "entities", "serverId": "default", "index": "entities_index" }, + { "namespaceId": "images", "serverId": "default", "index": "images_index" }, + { "namespaceId": "tr_passages", "serverId": "default", "index": "tr_passages_index" }, + { "namespaceId": "tr_clusters", "serverId": "default", "index": "tr_clusters_index" }, + { "namespaceId": "embeddings_de", "serverId": "default", "index": "index_embeddings_de" }, + { "namespaceId": "embeddings_fr", "serverId": "default", "index": "index_embeddings_fr" }, + { "namespaceId": "embeddings_lb", "serverId": "default", "index": "index_embeddings_lb" }, + { "namespaceId": "entities_mentions", "serverId": "default", "index": "mentions_entities_index" } + ] } } diff --git a/config/default.json b/config/default.json index 4687dde9..c7c86d67 100644 --- a/config/default.json +++ b/config/default.json @@ -28,7 +28,7 @@ "textReuse": { "enabled": true } }, "redis": { - "enable": true + "host": "localhost" }, "cache": { "enabled": true, @@ -134,63 +134,30 @@ "users": "auth_user" } }, - "solr": { - "host": "localhost", - "port": 8984, - "auth": { - "user": "", - "pass": "*****" - }, - "queries": { - "hasTextContents": "content_length_i:[1 TO *]" - }, - "search": { - "alias": "", - "endpoint": "https://.../select" - }, - "mentions": { - "alias": "", - "endpoint": "https://.../select", - "suggest": "https://.../suggest" - }, - "topics": { - "alias": "", - "endpoint": "https://.../select", - "suggest": "https://.../suggest" - }, - "images": { - "alias": "", - "endpoint": "https://.../select" - }, - "entities": { - "alias": "", - "endpoint": "https://.../select" - }, - "embeddings_de": { - "alias": "", - "endpoint": "https://.../select" - }, - "embeddings_fr": { - "alias": "", - "endpoint": "https://.../select" - }, - "embeddings_en": { - "alias": "", - "endpoint": "https://.../select" - }, - "embeddings_lb": { - "alias": "", - "endpoint": "https://.../select" - }, - "tr_passages": { - "endpoint": "https://.../select" - }, - "tr_clusters": { - "endpoint": "https://.../select" - }, - "entities_mentions": { - "endpoint": "https://.../select" - } + "solrConfiguration": { + "servers": [ + { + "id": "default", + "baseUrl": "https://localhost:8983/solr", + "auth": { + "read": { "username": "reader", "password": "..." }, + "write": { "username": "writer", "password": "..." } + } + } + ], + "namespaces": [ + { "namespaceId": "search", "serverId": "default", "index": "search_index" }, + { "namespaceId": "mentions", "serverId": "default", "index": "mentions_index" }, + { "namespaceId": "topics", "serverId": "default", "index": "topics_index" }, + { "namespaceId": "entities", "serverId": "default", "index": "entities_index" }, + { "namespaceId": "images", "serverId": "default", "index": "images_index" }, + { "namespaceId": "tr_passages", "serverId": "default", "index": "tr_passages_index" }, + { "namespaceId": "tr_clusters", "serverId": "default", "index": "tr_clusters_index" }, + { "namespaceId": "embeddings_de", "serverId": "default", "index": "index_embeddings_de" }, + { "namespaceId": "embeddings_fr", "serverId": "default", "index": "index_embeddings_fr" }, + { "namespaceId": "embeddings_lb", "serverId": "default", "index": "index_embeddings_lb" }, + { "namespaceId": "entities_mentions", "serverId": "default", "index": "mentions_entities_index" } + ] }, "recommender": { "byTopics": { diff --git a/src/cache.ts b/src/cache.ts index a90223ef..0e0ae992 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -17,7 +17,7 @@ const buildRedisUri = (config: Configuration['redis']): string => { export default (app: ImpressoApplication) => { const config = app.get('redis') const cacheConfig = app.get('cache') - const isEnabled = config?.enable && cacheConfig?.enabled + const isEnabled = cacheConfig?.enabled const redisStore = isEnabled ? new Keyv({ diff --git a/src/models/generated/common.d.ts b/src/models/generated/common.d.ts index 02d97ef0..b238a877 100644 --- a/src/models/generated/common.d.ts +++ b/src/models/generated/common.d.ts @@ -73,14 +73,10 @@ export interface Config { * Redis configuration */ export interface RedisConfig { - /** - * Enable Redis - */ - enable?: boolean; /** * Redis host */ - host: string; + host?: string; [k: string]: unknown; } /** diff --git a/src/redis.ts b/src/redis.ts index 29519da7..d5213819 100644 --- a/src/redis.ts +++ b/src/redis.ts @@ -12,7 +12,7 @@ type RedisClient = ReturnType export type { RedisClient } const getRedisClient = (config: RedisConfiguration): RedisClient => { - const { host, enable, ...redisConfig } = config + const { host, ...redisConfig } = config if (host != null) { redisConfig.url = `redis://${host}` } @@ -57,13 +57,11 @@ export default (app: ImpressoApplication) => { const config = app.get('redis') let client: RedisClient | undefined = undefined - if (!config?.enable) { - logger.info('Redis is not configured. No cache is available.') - } else { - logger.info("Redis configuration found, let's see if it works...") - client = getRedisClient(config) - logger.info('Redis client created.') - } + if (config == null) throw new Error('Redis config is missing') + + logger.info("Redis configuration found, let's see if it works...") + client = getRedisClient(config) + logger.info('Redis client created.') // Create the redis client container. const container = new RedisClientContainer(client) diff --git a/src/schema/common/config.json b/src/schema/common/config.json index b92802c8..160b33e0 100644 --- a/src/schema/common/config.json +++ b/src/schema/common/config.json @@ -197,11 +197,9 @@ "RedisConfig": { "type": "object", "properties": { - "enable": { "type": "boolean", "description": "Enable Redis" }, "host": { "type": "string", "description": "Redis host" } }, "description": "Redis configuration", - "required": ["host"], "additionalProperties": true }, "CeleryConfig": {