-
Notifications
You must be signed in to change notification settings - Fork 1
Stateless grpc connection #19
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
base: master
Are you sure you want to change the base?
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 good 👏
lib/util/grpc.ex
Outdated
Util.Grpc.Client.new(:billing_service, "localhost:50051", BillingApi.Stub) | ||
]) | ||
|
||
3. User Grpc.do to communicate with your upstream services: |
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.
3. User Grpc.do to communicate with your upstream services: | |
3. User Grpc.call to communicate with your upstream services: |
lib/util/grpc.ex
Outdated
2. Sends the RPC request | ||
3. Waits for the result, or times out | ||
""" | ||
@spec rpc(client_name(), GRPC.Channel.t(), function()) :: |
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.
@spec rpc(client_name(), GRPC.Channel.t(), function()) :: | |
@spec call(client_name(), GRPC.Channel.t(), function()) :: |
lib/util/grpc/state.ex
Outdated
end | ||
|
||
def find_client(name) do | ||
Agent.get(__MODULE__, fn state -> Map.fetch!(state, name) end) |
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.
Minor thing: Agent.get/2
callback is executed internally by Agent process, and Map.fetch! raises unhandled exception in case of failure. Calling find_client/1
with unknown name will crash the State, not sure if that's by design?
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.
Good point. I'll have to fix it ✍️
{:ok, result} | ||
|
||
{:error, err} -> | ||
inc(rpc, "response.error.count") |
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.
Sometimes we send:ok response, and an error status is present in the status field. Can we check if this field is there and log accordingly?
e8cd47d
to
a45ab9e
Compare
Disclaimer: This is still a draft, tests, and code quality are still pretty poor.
There are several errors that still need to be caught.
I'm attaching you to check out the public API of the clients.
edit: I can't attach @mattrym for some reason. I'm pinging you directly.