Sobes.tech
Senior

When validation passes — do we record it in the database or send it further to Kafka?

sobes.tech AI

Answer from AI

The decision whether to record the validation result in the database or to send it further to Kafka depends on the system's architecture and requirements.

If long-term preservation and the possibility of subsequent auditing are important, it is advisable to first record the result in the database. This allows tracking the status and details of validation.

If the system is oriented towards asynchronous processing and scalability, then after successful validation, an event can be sent to Kafka for further processing by other services.

A common approach is a combined method: recording in the database for reliability and sending to Kafka for reactive processing.

Example in Go (simplified):

if err := validate(data); err == nil {
    err = db.Save(validationResult)
    if err != nil {
        // handle save error
    }
    kafkaProducer.Send(validationResult)
} else {
    // handle validation error
}
When validation passes — do we record it in the… - sobes.tech