-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathcorrelation.go
More file actions
30 lines (24 loc) · 744 Bytes
/
correlation.go
File metadata and controls
30 lines (24 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package cqrs
import (
"time"
)
// CQRSErrorEventType ...
const CQRSErrorEventType = "cqrs.ErrorEvent"
// ErrorEvent is a generic event raised within the CQRS framework
type ErrorEvent struct {
Message string
}
// DeliverCQRSError will deliver a CQRS error
func DeliverCQRSError(correlationID string, err error, repo EventSourcingRepository) {
err = repo.GetEventStreamRepository().SaveIntegrationEvent(VersionedEvent{
ID: "ve:" + NewUUIDString(),
CorrelationID: correlationID,
SourceID: "",
Version: 0,
EventType: CQRSErrorEventType,
Created: time.Now(),
Event: ErrorEvent{Message: err.Error()}})
if err != nil {
PackageLogger().Debugf("ERROR saving integration event: %v\n", err)
}
}