-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
59 lines (52 loc) · 1.74 KB
/
types.go
File metadata and controls
59 lines (52 loc) · 1.74 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"go.mongodb.org/mongo-driver/bson/primitive"
"time"
)
type Status struct {
Status string `json:"status" bson:"status"`
RetryCount int `json:"retryCount" bson:"retry_count"`
}
type Info struct {
Id int `json:"id" bson:"user_id"`
Name string `json:"name" bson:"name"`
Email string `json:"email" bson:"email"`
}
type Event struct {
Id primitive.ObjectID `json:"id" bson:"_id"`
EventType string `json:"eventType" bson:"event_type"`
Status string `json:"status" bson:"status"`
Payload Info `json:"payload" bson:"payload"`
RetryCount int `json:"retryCount" bson:"retry_count"`
CreatedAt time.Time `json:"createdAt" bson:"created_at"`
UpdatedAt time.Time `json:"updatedAt" bson:"updated_at"`
}
type DeadEvent struct{
Id primitive.ObjectID `json:"id" bson:"_id"`
EventType string `json:"eventType" bson:"event_type"`
Payload Info `json:"payload" bson:"payload"`
CreatedAt time.Time `json:"createdAt" bson:"created_at"`
FailedAt time.Time `json:"failedAt" bson:"failed_at"`
FailureReason string `json:"failureReason" bson:"failure_reason"`
}
func NewDeadEvent(event *Event,failureReason string,failureTime time.Time)*DeadEvent{
return &DeadEvent{
Id: event.Id,
FailedAt: failureTime,
FailureReason: failureReason,
Payload: event.Payload,
CreatedAt: event.CreatedAt,
EventType: event.EventType,
}
}
func NewRegisterEvent(information Info) *Event {
return &Event{
Id: primitive.NewObjectID(),
EventType: "user_registration",
Payload: information,
RetryCount: 0,
Status: "pending",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
}