fix: prepare native cluster deployment

This commit is contained in:
richjohnrambo
2026-09-21 13:52:34 +08:00
parent 5f717c2162
commit 407842db91
7 changed files with 754 additions and 18 deletions
+8 -5
View File
@@ -38,8 +38,10 @@ type cacheInvalidatePayload struct {
Ranges []types.Range `json:"ranges"`
}
var kafkaCacheInvalidateConsumerGroup string
func startKafkaCacheInvalidateConsumer() {
startKafkaConsumer("cache_invalidate", handleKafkaCacheInvalidateEvent)
kafkaCacheInvalidateConsumerGroup = startKafkaBroadcastConsumer("cache_invalidate", handleKafkaCacheInvalidateEvent)
}
func handleKafkaCacheInvalidateEvent(ctx context.Context, envelope kafkaEnvelope, _ kafka.Message) error {
@@ -50,17 +52,18 @@ func handleKafkaCacheInvalidateEvent(ctx context.Context, envelope kafkaEnvelope
if tenantID.IsZero() {
tenantID = types.TenantID(1)
}
consume, claimed, err := beginKafkaConsumeForTopic(tenantID, envelope, "cache_invalidate")
consumerGroup := kafkaCacheInvalidateConsumerGroup
consume, claimed, err := beginKafkaConsumeForTopicWithGroup(tenantID, envelope, "cache_invalidate", consumerGroup)
if err != nil {
return err
}
if !claimed {
logs.Info.Printf("kafka cache invalidate skipped: event=%s group=%s status=%s", envelope.EventID, kafkaBus.config.ConsumerGroup, consume.Status)
logs.Info.Printf("kafka cache invalidate skipped: event=%s group=%s status=%s", envelope.EventID, consumerGroup, consume.Status)
return nil
}
if err = executeKafkaCacheInvalidateEvent(envelope); err != nil {
reason := kafkaCommandErrorReason(err)
failed, markErr := store.HTTPInfrastructure.MarkKafkaConsumeFailed(tenantID, envelope.EventID, kafkaBus.config.ConsumerGroup, reason, err.Error(), time.Now().UTC().Round(time.Millisecond))
failed, markErr := store.HTTPInfrastructure.MarkKafkaConsumeFailed(tenantID, envelope.EventID, consumerGroup, reason, err.Error(), time.Now().UTC().Round(time.Millisecond))
if markErr != nil {
return markErr
}
@@ -70,7 +73,7 @@ func handleKafkaCacheInvalidateEvent(ctx context.Context, envelope kafkaEnvelope
sleepKafkaRetryBackoff(failed.RetryCount)
return err
}
return store.HTTPInfrastructure.MarkKafkaConsumeSucceeded(tenantID, envelope.EventID, kafkaBus.config.ConsumerGroup, time.Now().UTC().Round(time.Millisecond))
return store.HTTPInfrastructure.MarkKafkaConsumeSucceeded(tenantID, envelope.EventID, consumerGroup, time.Now().UTC().Round(time.Millisecond))
}
func executeKafkaCacheInvalidateEvent(envelope kafkaEnvelope) error {