feat(events): add idempotent Kafka event consumer runtime
This commit is contained in:
1 parent
565ef8d4f5
commit
3adb0ef9e4
47 files changed
+5018
-105
No files matched your search
@@ -69,7 +69,7 @@ type DomainEventInput struct {
|
||||
// NewDomainEvent validates input and assigns a time-ordered UUIDv7 event ID.
|
||||
// The stored payload is the compact form of input.Payload.
|
||||
func NewDomainEvent(input DomainEventInput) (DomainEvent, error) {
|
||||
if err := input.validateIdentity(); err != nil {
|
||||
if err := input.ValidateIdentity(); err != nil {
|
||||
return DomainEvent{}, err
|
||||
}
|
||||
payload, err := compactPayload(input.Payload)
|
||||
@@ -91,7 +91,9 @@ func NewDomainEvent(input DomainEventInput) (DomainEvent, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (input DomainEventInput) validateIdentity() error {
|
||||
// ValidateIdentity checks every field except the payload. Event consumers
|
||||
// use it to apply the same rules to an event read from the event bus.
|
||||
func (input DomainEventInput) ValidateIdentity() error {
|
||||
if len(input.EventType) > maxDomainEventTypeLength || !domainEventTypePattern.MatchString(input.EventType) {
|
||||
return invalidDomainEvent("event type must be a lowercase dotted name of at most 128 bytes")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user