File tree Expand file tree Collapse file tree 5 files changed +34
-16
lines changed
Backoffice/Courses/infrastructure/persistence
Shared/infrastructure/persistence/elasticsearch
apps/backoffice/backend/config/dependency-injection Expand file tree Collapse file tree 5 files changed +34
-16
lines changed Original file line number Diff line number Diff line change 1+ import config from '../../../../../apps/backoffice/backend/config/config' ;
2+ import ElasticConfig from '../../../../Shared/infrastructure/persistence/elasticsearch/ElasticConfig' ;
3+
4+ export class BackofficeElasticConfigFactory {
5+ static createConfig ( ) : ElasticConfig {
6+ return {
7+ url : config . get ( 'elastic.url' )
8+ } ;
9+ }
10+ }
Original file line number Diff line number Diff line change 11import { Client as ElasticClient } from '@elastic/elasticsearch' ;
2- import config from '../../../../../apps/backoffice/backend/config/config' ;
32import { Nullable } from '../../../domain/Nullable' ;
3+ import ElasticConfig from './ElasticConfig' ;
44
55export class ElasticClientFactory {
66 private static clients : { [ key : string ] : ElasticClient } = { } ;
77
8- static async createClient ( contextName : string ) : Promise < ElasticClient > {
8+ static async createClient ( contextName : string , config : ElasticConfig ) : Promise < ElasticClient > {
99 let client = ElasticClientFactory . getClient ( contextName ) ;
1010
1111 if ( ! client ) {
12- client = await ElasticClientFactory . createAndConnectClient ( ) ;
12+ client = await ElasticClientFactory . createAndConnectClient ( config ) ;
1313
1414 ElasticClientFactory . registerClient ( client , contextName ) ;
1515 }
@@ -21,8 +21,8 @@ export class ElasticClientFactory {
2121 return ElasticClientFactory . clients [ contextName ] ;
2222 }
2323
24- private static async createAndConnectClient ( ) : Promise < ElasticClient > {
25- const client = new ElasticClient ( { node : config . get ( 'elastic. url' ) } ) ;
24+ private static async createAndConnectClient ( config : ElasticConfig ) : Promise < ElasticClient > {
25+ const client = new ElasticClient ( { node : config . url } ) ;
2626
2727 return client ;
2828 }
Original file line number Diff line number Diff line change 1+ type ElasticConfig = { url : string } ;
2+
3+ export default ElasticConfig ;
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ services:
1313 factory :
1414 class : ../../../../../../Contexts/Shared/infrastructure/persistence/elasticsearch/ElasticClientFactory
1515 method : ' createClient'
16- arguments : ['mooc']
16+ arguments : ['mooc', '@Apps.Backoffice.Backend.ElasticConfig' ]
1717
1818 Shared.QueryHandlersInformation :
1919 class : ../../../../../../Contexts/Shared/infrastructure/QueryBus/QueryHandlersInformation
Original file line number Diff line number Diff line change 11services :
2- Apps.Backoffice.Backend.MongoConfig :
3- factory :
4- class : ../../../../../../Contexts/Backoffice/Courses/infrastructure/persistence/BackofficeMongoConfigFactory
5- method : ' createConfig'
2+ Apps.Backoffice.Backend.MongoConfig :
3+ factory :
4+ class : ../../../../../../Contexts/Backoffice/Courses/infrastructure/persistence/BackofficeMongoConfigFactory
5+ method : ' createConfig'
66
7- Apps.Backoffice.Backend.controllers.StatusGetController :
8- class : ../../../controllers/StatusGetController
9- arguments : []
7+ Apps.Backoffice.Backend.ElasticConfig :
8+ factory :
9+ class : ../../../../../../Contexts/Backoffice/Courses/infrastructure/persistence/BackofficeElasticConfigFactory
10+ method : ' createConfig'
1011
11- Apps.Backoffice.Backend.controllers.CoursesGetController :
12- class : ../../../controllers/CoursesGetController
13- arguments : ['@Shared.QueryBus']
12+ Apps.Backoffice.Backend.controllers.StatusGetController :
13+ class : ../../../controllers/StatusGetController
14+ arguments : []
15+
16+ Apps.Backoffice.Backend.controllers.CoursesGetController :
17+ class : ../../../controllers/CoursesGetController
18+ arguments : ['@Shared.QueryBus']
You can’t perform that action at this time.
0 commit comments