Skip to content

Commit 145c366

Browse files
Remove reflection need for notification log
1 parent 195e54d commit 145c366

File tree

8 files changed

+27
-9
lines changed

8 files changed

+27
-9
lines changed

driver/sql/postgres/projector_aggregate.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ func (a *AggregateProjector) processNotification(
162162
// Resolve the action to take based on the error that occurred
163163
logFields := func(e goengine.LoggerEntry) {
164164
e.Error(err)
165-
e.Any("notification", notification)
165+
e.Int64("notification.no", notification.No)
166+
e.String("notification.aggregate_id", notification.AggregateID)
166167
}
167168
switch resolveErrorAction(a.projectionErrorHandler, notification, err) {
168169
case errorFail:
@@ -231,13 +232,15 @@ func (a *AggregateProjector) triggerOutOfSyncProjections(ctx context.Context, qu
231232
if err := queue(ctx, notification); err != nil {
232233
a.logger.Error("failed to queue notification", func(e goengine.LoggerEntry) {
233234
e.Error(err)
234-
e.Any("notification", notification)
235+
e.Int64("notification.no", notification.No)
236+
e.String("notification.aggregate_id", notification.AggregateID)
235237
})
236238
return err
237239
}
238240

239241
a.logger.Debug("send catchup", func(e goengine.LoggerEntry) {
240-
e.Any("notification", notification)
242+
e.Int64("notification.no", notification.No)
243+
e.String("notification.aggregate_id", notification.AggregateID)
241244
})
242245
}
243246

driver/sql/postgres/projector_aggregate_storage.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ func (a *aggregateProjectionStorage) PersistState(conn driverSQL.Execer, notific
130130
}
131131

132132
a.logger.Debug("updated projection state", func(e goengine.LoggerEntry) {
133-
e.Any("notification", notification)
133+
e.Int64("notification.no", notification.No)
134+
e.String("notification.aggregate_id", notification.AggregateID)
134135
e.Any("state", state)
135136
})
136137
return nil
@@ -150,7 +151,8 @@ func (a *aggregateProjectionStorage) Acquire(
150151
notification *driverSQL.ProjectionNotification,
151152
) (func(), *driverSQL.ProjectionRawState, error) {
152153
logFields := func(e goengine.LoggerEntry) {
153-
e.Any("notification", notification)
154+
e.Int64("notification.no", notification.No)
155+
e.String("notification.aggregate_id", notification.AggregateID)
154156
}
155157
aggregateID := notification.AggregateID
156158

driver/sql/postgres/projector_stream.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ func (s *StreamProjector) processNotification(
148148
// Resolve the action to take based on the error that occurred
149149
logFields := func(e goengine.LoggerEntry) {
150150
e.Error(err)
151-
e.Any("notification", notification)
151+
e.Int64("notification.no", notification.No)
152+
e.String("notification.aggregate_id", notification.AggregateID)
152153
}
153154
switch resolveErrorAction(s.projectionErrorHandler, notification, err) {
154155
case errorRetry:

driver/sql/postgres/projector_stream_storage.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ func (s *streamProjectionStorage) PersistState(conn driverSQL.Execer, notificati
108108
return err
109109
}
110110
s.logger.Debug("updated projection state", func(e goengine.LoggerEntry) {
111-
e.Any("notification", notification)
111+
e.Int64("notification.no", notification.No)
112+
e.String("notification.aggregate_id", notification.AggregateID)
112113
e.Any("state", state)
113114
})
114115

@@ -121,7 +122,8 @@ func (s *streamProjectionStorage) Acquire(
121122
notification *driverSQL.ProjectionNotification,
122123
) (func(), *driverSQL.ProjectionRawState, error) {
123124
logFields := func(e goengine.LoggerEntry) {
124-
e.Any("notification", notification)
125+
e.Int64("notification.no", notification.No)
126+
e.String("notification.aggregate_id", notification.AggregateID)
125127
}
126128

127129
var res *sql.Row

extension/logrus/logrus.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ func (e entry) Int(k string, v int) {
9595
e[k] = v
9696
}
9797

98+
func (e entry) Int64(k string, v int64) {
99+
e[k] = v
100+
}
101+
98102
func (e entry) String(k, v string) {
99103
e[k] = v
100104
}

extension/pq/listener.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ func (s *Listener) unmarshalNotification(n *pq.Notification) *sql.ProjectionNoti
153153

154154
s.logger.Debug("received notification", func(e goengine.LoggerEntry) {
155155
e.Any("pq_notification", n)
156-
e.Any("notification", notification)
156+
e.Int64("notification.no", notification.No)
157+
e.String("notification.aggregate_id", notification.AggregateID)
157158
})
158159

159160
return notification

extension/zap/zap.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ func (e *entry) Int(k string, v int) {
6565
e.fields = append(e.fields, zap.Int(k, v))
6666
}
6767

68+
func (e *entry) Int64(k string, v int64) {
69+
e.fields = append(e.fields, zap.Int64(k, v))
70+
}
71+
6872
func (e *entry) String(k, v string) {
6973
e.fields = append(e.fields, zap.String(k, v))
7074
}

logger.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type (
1515
// This entry can be enhanced with more date.
1616
LoggerEntry interface {
1717
Int(k string, v int)
18+
Int64(s string, v int64)
1819
String(k, v string)
1920
Error(err error)
2021
Any(k string, v interface{})

0 commit comments

Comments
 (0)