Skip to content

Integration

@nx/search tích hợp bằng cách được nhúng, không gọi qua mạng. Host đăng ký các component của nó và dùng SearchService + SearchableControllerMixin in-process.

1. Service anh em

SisterDirectionSurfaceContractAuthFailure Mode
commerce (host)In-process — đăng ký 4 component, gọi SearchService, áp dụng SearchableControllerMixinLibrary APIKế thừa (host JWT/Basic)Exception in-process
@nx/coreConfigurationRepository, CdcTables, EnvironmentKeys, SystemConfigurationsLibraryDependency compile-time

Commerce áp dụng mixin lên các controller organizer / merchant / category / device / sale-channel / product / product-variant của nó, mỗi cái override resolveSearchScope() để inject một scope where merchant/tenant.

2. Hệ thống bên ngoài

SystemDirectionSurfaceAuthFailure Mode
TypesenseHTTP (typesense client) — search, import, collection CRUD, healthAPI key (APP_ENV_TYPESENSE_API_KEY)Health probe → circuit breaker pause CDC; lỗi search được phân loại + retry
Kafka + DebeziumConsume CDC topics (@platformatic/kafka, Avro qua avsc)SASL tùy chọn (APP_ENV_KAFKA_SASL_*)DLQ cho message độc; offset không commit khi fail

3. Luồng cross-service quan trọng

3.1 Consumer nối search theo từng entity (build-time)

BướcChi tiết
2Nodes parse từ CSV protocol:host:port; mặc định http:localhost:8108
6embed.from chỉ nối khi có config embedding DB + collection có embeddingField/embeddingFields
7Collection thiếu được tạo; cái đã phân kỳ được log (migration thủ công)

3.2 Search scope theo tenant lúc request

BướcChi tiết
2Override của host trả về một object where; mixin and-merge nó với filter của caller
3Scope rỗng (null) nghĩa là search mở (không giới hạn tenant)

4. Tính ổn định Contract

SurfaceStabilityVersioning
Thứ tự đăng ký componentstableLibrary semver (@nx/search)
SearchableControllerMixin(Base, options)stableLibrary semver
ISearchParams / ISearchResponsestableLibrary types
GET /search/{collectionName} (controller generic)stableHost URL /v1/
Tên CDC topic (nx.seller.{schema}.{table})ghép với config Debezium connectorDo connector sở hữu
Schema Typesense collectiontiến hóa (additive qua script backfill)Migration thủ công khi phân kỳ

5. Trang liên quan

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.