-
Notifications
You must be signed in to change notification settings - Fork 214
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
Provide a mechanism to inject a custom status handler #171
Provide a mechanism to inject a custom status handler #171
Conversation
@tony612 could you review it when you have time, please? |
@carrascoacd is this still relevant? |
lib/grpc/adapter/cowboy.ex
Outdated
]) | ||
# Custom handler to be able to listen in the same port, more info: | ||
# https://github.com/containous/traefik/issues/6211 | ||
status_handler = Application.get_env(:grpc, :status_handler) |
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.
I think we should avoid using global config as per the general library guidelines for Elixir. Instead, we should accept this through opts
.
Is this able to be passed down already, or would something more need to change?
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.
Hi @polvalente, thanks for answering. This is something we still need. Let me try injecting the configuration using opts
and check if it works.
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.
@polvalente I managed to get it working in that way. When starting the server under a Supervisor we get something like this:
status_handler = {"/status", Plug.Cowboy.Handler, {GrpcEx.StatusHandler, []}}
children = [
supervisor(GRPC.Server.Supervisor, [{GrpcEx.Endpoint, 50051, adapter_opts: [status_handler: status_handler]}])
]
Let me know if it works for you and I'll submit the changes.
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.
Yes! This is what I had in mind.
The benefit of doing it this way is that 2 processes can be started with different configs
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.
Great, much better. I've submitted the change!
Problem
In order to support Traefik we need to listen in the same port the h1 health checks, more info here traefik/traefik#6211
Expected outcome
Add a way to inject a custom status handler, so we can listen for h1 requests in the same port using the desired handler.
Let me know if it works for you in order to update the doc as well or if you have another solution.
The configuration could be: