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

[CHANGED] Use interface instead of struct for micro.Request #1174

Merged
merged 3 commits into from
Jan 3, 2023

Conversation

piotrpio
Copy link
Collaborator

@piotrpio piotrpio commented Dec 29, 2022

  • changed micro.Request to an interface
  • moved tests to test package

@coveralls
Copy link

coveralls commented Dec 29, 2022

Coverage Status

Coverage: 85.528% (+0.03%) from 85.495% when pulling 4179638 on service-request-interface into 07b2b8f on main.

micro/request.go Outdated
}

// RequestHandler is a function used as a Handler for a service.
RequestHandler func(*Request)
RequestHandler func(Request)
Copy link
Member

@wallyqs wallyqs Dec 29, 2022

Choose a reason for hiding this comment

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

Handler could be interface based here too a la http.Handler, that would make it convenient to pass around types that can handle requests, think something like this:

// micro.RequestHandler
type RequestHandler func(Request)
func (fn RequestHandler) Handle(req Request) {
  fn(req)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very good idea, thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

micro/example_test.go Outdated Show resolved Hide resolved
@piotrpio piotrpio requested a review from wallyqs January 3, 2023 17:58
micro/request.go Outdated Show resolved Hide resolved
Co-authored-by: Waldemar Quevedo <wally@nats.io>
Copy link
Member

@wallyqs wallyqs left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@piotrpio piotrpio merged commit aeead72 into main Jan 3, 2023
@piotrpio piotrpio deleted the service-request-interface branch January 3, 2023 20:51
@piotrpio piotrpio mentioned this pull request Jan 18, 2023
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.

None yet

4 participants