Skip to content

Commit

Permalink
updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
theorm committed Jan 2, 2025
1 parent 755afe5 commit 24f2588
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 93 deletions.
44 changes: 25 additions & 19 deletions config/default.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"max": 50
},
"redis": {
"enable": false
"host": "localhost"
},
"rateLimiter": {
"enabled": false,
Expand Down Expand Up @@ -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" }
]
}
}
83 changes: 25 additions & 58 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"textReuse": { "enabled": true }
},
"redis": {
"enable": true
"host": "localhost"
},
"cache": {
"enabled": true,
Expand Down Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 1 addition & 5 deletions src/models/generated/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
/**
Expand Down
14 changes: 6 additions & 8 deletions src/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type RedisClient = ReturnType<typeof createClient>
export type { RedisClient }

const getRedisClient = (config: RedisConfiguration): RedisClient => {
const { host, enable, ...redisConfig } = config
const { host, ...redisConfig } = config
if (host != null) {
redisConfig.url = `redis://${host}`
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/schema/common/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 24f2588

Please sign in to comment.