Skip to content
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

Signature handler refactor #495

Merged
merged 2 commits into from
Feb 7, 2023

Conversation

aaronbuchwald
Copy link
Collaborator

Why this should be merged

This PR re-organizes the stats and handlers and reduces the duplicated stats code.

How this works

This PR uses the embedded stats and handlers rather than duplicating function calls to do many passthroughs to the underlying stats.

How this was tested

This PR is tested in CI

How is this documented

no documentation necessary for this change

)

var (
_ SignatureRequestHandlerStats = (*handlerStats)(nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to figure out difference between (*handlerStats)(nil) and &handlerStats{}, is it the difference between nil and a default struct value?

Should we always use (*struct)(nil) i'm thinking for MockHandlerStats etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're both used to ensure that the struct implements the interface.

I've switched to using (*type)(nil). It doesn't make much of a difference and tbh we should be consistent, but currently use both in different places.

Here's one article: https://splice.com/blog/golang-verify-type-implements-interface-compile-time/.

@aaronbuchwald aaronbuchwald merged commit 56dc93b into signature-handler Feb 7, 2023
@aaronbuchwald aaronbuchwald deleted the signature-handler-refactor branch February 7, 2023 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants