feat(index): Only run the synchronisation in worker/shared mode (#12530)
* feat(index): Only run the synchronisation in worker/shared mode * Create dirty-trees-smoke.md
This commit is contained in:
1 parent
ac49eb9a6c
commit
dd66720404
2 files changed
+17
-1
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/index": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(index): Only run the synchronisation in worker/shared mode
|
||||||
@@ -40,6 +40,8 @@ export default class IndexModuleService
|
|||||||
extends ModulesSdkUtils.MedusaService({})
|
extends ModulesSdkUtils.MedusaService({})
|
||||||
implements IndexTypes.IIndexService
|
implements IndexTypes.IIndexService
|
||||||
{
|
{
|
||||||
|
#isWorkerMode: boolean = false
|
||||||
|
|
||||||
private readonly container_: InjectedDependencies
|
private readonly container_: InjectedDependencies
|
||||||
private readonly moduleOptions_: IndexTypes.IndexModuleOptions
|
private readonly moduleOptions_: IndexTypes.IndexModuleOptions
|
||||||
|
|
||||||
@@ -83,6 +85,8 @@ export default class IndexModuleService
|
|||||||
this.moduleOptions_ = (moduleDeclaration.options ??
|
this.moduleOptions_ = (moduleDeclaration.options ??
|
||||||
moduleDeclaration) as unknown as IndexTypes.IndexModuleOptions
|
moduleDeclaration) as unknown as IndexTypes.IndexModuleOptions
|
||||||
|
|
||||||
|
this.#isWorkerMode = moduleDeclaration.worker_mode !== "server"
|
||||||
|
|
||||||
const {
|
const {
|
||||||
[Modules.EVENT_BUS]: eventBusModuleService,
|
[Modules.EVENT_BUS]: eventBusModuleService,
|
||||||
storageProviderCtr,
|
storageProviderCtr,
|
||||||
@@ -126,6 +130,11 @@ export default class IndexModuleService
|
|||||||
|
|
||||||
await gqlSchemaToTypes(executableSchema!)
|
await gqlSchemaToTypes(executableSchema!)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only run the data synchronization in worker mode
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (this.#isWorkerMode) {
|
||||||
this.dataSynchronizer_.onApplicationStart({
|
this.dataSynchronizer_.onApplicationStart({
|
||||||
schemaObjectRepresentation: this.schemaObjectRepresentation_,
|
schemaObjectRepresentation: this.schemaObjectRepresentation_,
|
||||||
storageProvider: this.storageProvider_,
|
storageProvider: this.storageProvider_,
|
||||||
@@ -138,11 +147,13 @@ export default class IndexModuleService
|
|||||||
indexSyncService: this.indexSyncService_,
|
indexSyncService: this.indexSyncService_,
|
||||||
dataSynchronizer: this.dataSynchronizer_,
|
dataSynchronizer: this.dataSynchronizer_,
|
||||||
})
|
})
|
||||||
const entitiesMetadataChanged = await configurationChecker.checkChanges()
|
const entitiesMetadataChanged =
|
||||||
|
await configurationChecker.checkChanges()
|
||||||
|
|
||||||
if (entitiesMetadataChanged.length) {
|
if (entitiesMetadataChanged.length) {
|
||||||
await this.dataSynchronizer_.syncEntities(entitiesMetadataChanged)
|
await this.dataSynchronizer_.syncEntities(entitiesMetadataChanged)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger_.error(e)
|
this.logger_.error(e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user