Gate gRPC control plane startup behind API flag#6
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f062d4b19e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| @doc false | ||
| def grpc_child_specs do | ||
| if Config.boolean("MN_API_ENABLED", :api_enabled) do |
There was a problem hiding this comment.
Skip gRPC port validation when API is disabled
When MN_API_ENABLED=false, this gate suppresses the gRPC child, but start/2 still calls Config.validate!/0 first, and that unconditionally validates MN_GRPC_PORT in lib/mirror_neuron/config.ex. In a deployment that disables the API listener and has an intentionally unset/non-port placeholder for MN_GRPC_PORT, the application still fails during startup even though the port will never be used, so the new disable flag does not fully prevent gRPC startup requirements from applying.
Useful? React with 👍 / 👎.
Motivation
Description
grpc_child_specs/0helper that only returns theGRPC.Server.Supervisorspec whenMN_API_ENABLEDis true (viaConfig.boolean("MN_API_ENABLED", :api_enabled)).MN_GRPC_PORTandMN_CORE_HOSTand by keeping the loopback default binding whenMN_CORE_HOSTis empty orlocalhost.tests/unit/application_test.exswith unit coverage asserting the gRPC child spec is omitted when the API is disabled and produced (with loopback binding) when enabled.README.mdto document thatMN_API_ENABLEDcontrols the gRPC listener and that the defaultMN_CORE_HOSTis loopback-only.Testing
mix format --check-formattedwhich passed locally for the modified files.elixir -e 'Code.string_to_quoted!(File.read!(...))'which validated the modified modules as syntactically correct.MirrorNeuron.Application.grpc_child_specs()under bothMN_API_ENABLED=falseandMN_API_ENABLED=trueto confirm the expected child-spec behavior (observed expected results).mix testandmix test tests/unit/application_test.exs, but fetching Hex/dependencies failed due to an external HTTP/SSL error (mix local.hex --force/mix deps.getfailed with an HTTP 403 SSL tunnel error), so automated test execution was blocked and full test-suite results are unavailable.Codex Task