-
-
Notifications
You must be signed in to change notification settings - Fork 95
verification: Clean up logging when checking transaction IDs #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| log = log.With().Stringer("transaction_id", transactionID).Logger() | ||
|
|
||
| vh.activeTransactionsLock.Lock() | ||
| defer vh.activeTransactionsLock.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing to use defer and changing this to return a *VerificationTransaction should be the only changes to this code after factoring it out.
| Stringer("sender", evt.Sender). | ||
| Stringer("room_id", evt.RoomID). | ||
| Stringer("event_id", evt.ID). | ||
| Stringer("event_type", evt.Type). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note, this change looses the event_type key from the callback's logger. I'm not sure how useful it is (and it might be added to the context somewhere else).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed!
sumnerevans
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The defer is a really nice refactor. It's a lot cleaner than what I wrote 😂
The
wrapHandlerwas nesting contexts, so when adding theverification_action=check transaction IDportion it reused that same context when calling the supplied callback, which then added a new set of parameters and duplicatedverification_actionand others.Also refactor checkTransactionID into it's own function so it's easier to read as it's own step, make it clear we throw away that derived context with the fields, and take advantage of
deferfor unlocking.