feat(projection-writer): Kafka consumer + Redis materialization per-locale
ordinis-projection-writer полностью реализован, last module:
- OrdinisProjectionWriterApplication: Spring Boot main + JpaRepositories
- RedisKeys: convention 'ord:<bundle>:<dictionary>:<bk>:<locale>' для flat
плюс ':_raw' для multi-locale, плюс 'ord:idx:<bundle>:<dictionary>' set index
- ProjectionWriter: для каждой supported locale справочника flatten data и
записать в Redis. Также пишет _raw multi-locale ключ. На delete стирает
все варианты + удаляет из index. Метрики ordinis_projection_records_*
- RecordEventListener: @KafkaListener на 3 scope-топика, group
ordinis-projection-cuod. Парсит EventEnvelope, разбирает payload.type
(RecordCreated/Updated/Deleted), вызывает upsert или delete.
- application.yml profile-based: dev (port-forward), k8s (Vault role
ordinis-projection-writer)
- logback-spring.xml как у других сервисов
ordinis-events-api: добавлен явный 'type' accessor в каждом record
(@JsonProperty type). Без него Jackson не сериализовал discriminator
из @JsonTypeInfo (при generic T payload Jackson не знает declared type).
ordinis-infra: Redis StatefulSet (redis:7.4-alpine, AOF, maxmemory 256mb
LRU, secret password) в namespace ordinis-dev на :6379.
E2E (3 сервиса параллельно):
POST /spacecraft/records {AQUA-1, name:{ru-RU:'Аква',en-US:'Aqua'}, ...}
→ outbox row id=7 published_at=true
→ ordinis_outbox_published_total +1
→ projection log: 'Projection upserted: spacecraft:AQUA-1 (2 locales)'
→ Redis ord:cuod:spacecraft:AQUA-1:ru-RU = {name:'Аква',...}
→ Redis ord:cuod:spacecraft:AQUA-1:en-US = {name:'Aqua',...}
→ Redis ord:cuod:spacecraft:AQUA-1:_raw = {name:{ru-RU,en-US},...}
→ Redis ord:idx:cuod:spacecraft set member 'AQUA-1'
10 of 10 модулей реализованы. Last module done.
This commit is contained in:
+5
-1
@@ -21,4 +21,8 @@ public record DictionaryDefinitionCreated(
|
||||
List<String> supportedLocales,
|
||||
String defaultLocale,
|
||||
OffsetDateTime createdAt,
|
||||
String createdBy) implements DictionaryDefinitionEvent {}
|
||||
String createdBy) implements DictionaryDefinitionEvent {
|
||||
|
||||
@com.fasterxml.jackson.annotation.JsonProperty("type")
|
||||
public String type() { return "DefinitionCreated"; }
|
||||
}
|
||||
|
||||
+5
-1
@@ -26,4 +26,8 @@ public record DictionaryDefinitionUpdated(
|
||||
List<String> supportedLocales,
|
||||
String defaultLocale,
|
||||
OffsetDateTime updatedAt,
|
||||
String updatedBy) implements DictionaryDefinitionEvent {}
|
||||
String updatedBy) implements DictionaryDefinitionEvent {
|
||||
|
||||
@com.fasterxml.jackson.annotation.JsonProperty("type")
|
||||
public String type() { return "DefinitionUpdated"; }
|
||||
}
|
||||
|
||||
+5
-1
@@ -22,4 +22,8 @@ public record DictionaryRecordCreated(
|
||||
OffsetDateTime validFrom,
|
||||
OffsetDateTime validTo,
|
||||
OffsetDateTime createdAt,
|
||||
String createdBy) implements DictionaryRecordEvent {}
|
||||
String createdBy) implements DictionaryRecordEvent {
|
||||
|
||||
@com.fasterxml.jackson.annotation.JsonProperty("type")
|
||||
public String type() { return "RecordCreated"; }
|
||||
}
|
||||
|
||||
+5
-1
@@ -16,4 +16,8 @@ public record DictionaryRecordDeleted(
|
||||
OffsetDateTime closedAt,
|
||||
OffsetDateTime deletedAt,
|
||||
String deletedBy,
|
||||
String reason) implements DictionaryRecordEvent {}
|
||||
String reason) implements DictionaryRecordEvent {
|
||||
|
||||
@com.fasterxml.jackson.annotation.JsonProperty("type")
|
||||
public String type() { return "RecordDeleted"; }
|
||||
}
|
||||
|
||||
+5
-1
@@ -23,4 +23,8 @@ public record DictionaryRecordUpdated(
|
||||
OffsetDateTime validFrom,
|
||||
OffsetDateTime validTo,
|
||||
OffsetDateTime updatedAt,
|
||||
String updatedBy) implements DictionaryRecordEvent {}
|
||||
String updatedBy) implements DictionaryRecordEvent {
|
||||
|
||||
@com.fasterxml.jackson.annotation.JsonProperty("type")
|
||||
public String type() { return "RecordUpdated"; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user