-
Notifications
You must be signed in to change notification settings - Fork 1
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
Send RPC from skinny server #92
Conversation
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.
Looks grand, one comment about how you're creating the connection
skinny/main.go
Outdated
} | ||
addr := host + ":8000" | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
conn, err := grpc.Dial(addr, grpc.WithInsecure()) |
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.
In general, we shouldn't be creating grpc connections everytime we open a response, instead we should use an existing connection (via a client), and only make the connection once when the server is started.
we may want an s.greeter
that is the client, so it's easy to pass a mocked client in during a test
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.
s/response/request?
You're probably right, and I like the idea of s.greeter
. That fits the problem I was trying to figure out with passing in a mock in tests. I will change this.
I'd like to reformat the RPC services in the serverWrapper into some common struct or interface, so that there's just something like:
in the serverWrapper for each RPC service. This seems cleaner than holding a conn and a client for each individual RPC endpoint individually in the serverWrapper. However, because stuff with generics doesn't really work in Go, it's tough to do this with in a nice way for every I'll hopefully play with this again in future to find a nice way, but in the meantime, PTAL a this PR. |
Closes #55.
Get gRPC working on server. Shown here by contacting the greeting card example service.