-
Notifications
You must be signed in to change notification settings - Fork 12
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
Conversation
config/config.go
Outdated
Service string `json:"service"` | ||
Method string `json:"method"` | ||
Protocol string `json:"protocol,omitempty"` | ||
Service string `json:"service,omitempty"` |
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.
Shall we move these into a GrpcConfig
struct? Everything except Service
and Method
are applicable to both Http and grpc, right?
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.
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"` |
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.
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.
config/config_test.go
Outdated
{ | ||
name: "grpc proxy", | ||
configPath: "../internal/testdata/config/invalid_grpc_proxy.yaml", | ||
expectedErrMsg: "fiber: grpc dispatcher: missing config (endpoint/service/method/response-proto)", |
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.
We removed the response-proto
from the config, right? The error message from NewDispatcher
should be updated.
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 { |
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.
nit:
if route, err := routeConfig.initComponent(); err != nil {
return nil, err
}
routes[route.ID()] = route
thanks for the quick review! |
Description
Minor bugfix for grpc fiber
Changes
omitempty
to proxy struct'sprotocol, service, method
field, as these json fields are not required in HTTP setting