File tree 1 file changed +11
-15
lines changed
1 file changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -143,26 +143,22 @@ func publishInTransaction(m dsl.Matcher) {
143
143
144
144
// Match direct calls to the Publish method of a pubsub instance inside InTx
145
145
m .Match (`
146
- $db .InTx(func($tx $dbType) $retType {
146
+ $x .InTx(func($y) error {
147
147
$*_
148
- $ps.Publish($*args )
148
+ $_ = $ ps.Publish($evt, $msg )
149
149
$*_
150
- }, $*txopts)
151
- ` ).
152
- Where (m ["ps" ].Type .Implements ("pubsub.Pubsub" ) ||
153
- m ["ps" ].Text .Matches (`\w+\.pubsub` ) ||
154
- m ["ps" ].Text .Matches (`pubsub\.\w+` )).
155
- Report ("Avoid calling Publish inside database transactions as this may lead to connection deadlocks. Move the Publish call outside the transaction." )
156
-
157
- // Also catch publish calls on nested fields like c.pubsub.Publish()
158
- m .Match (`
159
- $db.InTx(func($tx $dbType) $retType {
150
+ }, $*_)
151
+ ` ,
152
+ // Without catching error return
153
+ `
154
+ $x.InTx(func($y) error {
160
155
$*_
161
- $ps.$field. Publish($*args )
156
+ $ps.Publish($evt, $msg )
162
157
$*_
163
- }, $*txopts )
158
+ }, $*_ )
164
159
` ).
165
- Where (m ["field" ].Text == "pubsub" ).
160
+ Where (m ["ps" ].Type .Is ("pubsub.Pubsub" )).
161
+ At (m ["ps" ]).
166
162
Report ("Avoid calling Publish inside database transactions as this may lead to connection deadlocks. Move the Publish call outside the transaction." )
167
163
}
168
164
You can’t perform that action at this time.
0 commit comments