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

Grpc fiber router integration #4

Merged
merged 4 commits into from
Sep 6, 2022

Conversation

leonlnj
Copy link
Contributor

@leonlnj leonlnj commented Sep 6, 2022

Description

Minor bugfix for grpc fiber

Changes

  • Handle unhandled error at config.go
  • Add negative test case for the above
  • Add omitempty to proxy struct's protocol, service, method field, as these json fields are not required in HTTP setting

@leonlnj leonlnj self-assigned this Sep 6, 2022
@leonlnj leonlnj requested review from pradithya and a team and removed request for a team September 6, 2022 03:56
config/config.go Outdated
Service string `json:"service"`
Method string `json:"method"`
Protocol string `json:"protocol,omitempty"`
Service string `json:"service,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we move these into a GrpcConfig struct? Everything except Service and Method are applicable to both Http and grpc, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Service and Method are only exclusive to grpc too.

For http, the url and method are set within http.Request of the Request payload. For grpc, this information is stored in dispatcher.

config/config.go Outdated
Protocol string `json:"protocol"`
Service string `json:"service"`
Method string `json:"method"`
Protocol string `json:"protocol,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this omitempty? I think it would be clearer to force the user to set this value instead of defaulting to http. We can update any depending projects (like Turing) accordingly, when we consume the latest Fiber changes.

{
name: "grpc proxy",
configPath: "../internal/testdata/config/invalid_grpc_proxy.yaml",
expectedErrMsg: "fiber: grpc dispatcher: missing config (endpoint/service/method/response-proto)",
Copy link
Contributor

Choose a reason for hiding this comment

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

We removed the response-proto from the config, right? The error message from NewDispatcher should be updated.

@krithika369
Copy link
Contributor

Added some comments, the rest LGTM. Thanks!

config/config.go Outdated
@@ -67,15 +67,16 @@ func (d Duration) MarshalJSON() ([]byte, error) {
}

// Routes takes in an object of type Routes and returns a map of each route's ID and the route
func (r Routes) Routes() map[string]fiber.Component {
func (r Routes) Routes() (map[string]fiber.Component, error) {
routes := make(map[string]fiber.Component)
for _, routeConfig := range r {
if route, err := routeConfig.initComponent(); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

nit:

		if route, err := routeConfig.initComponent(); err != nil {
			return nil, err
		}
		routes[route.ID()] = route

@leonlnj
Copy link
Contributor Author

leonlnj commented Sep 6, 2022

thanks for the quick review!

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.

3 participants