Bandit-only fork: drop Plug.Cowboy, add bandit_opts - #1
Merged
Conversation
Builds on PR akoutmos#266 (Bandit support) by simplifying the metrics server to Bandit-only and exposing transport-level configuration: - Collapse server_spec/5 to a single Bandit definition. Plug.Cowboy branch and the cowboy_opts/pool_size config keys are removed. - Promote :bandit and :plug to required deps; drop :plug_cowboy. - New :bandit_opts keyword in metrics_server config is spliced into Bandit.child_spec/1 (with defensive Keyword.drop for :scheme/:plug/ :port). Lets callers pass thousand_island_options through, e.g. reuseport/reuseaddr for blue/green hot deploys. - Tests for bandit_opts parsing and child-spec injection. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds on upstream #266 (Bandit support), then simplifies the metrics server to Bandit-only and exposes transport-level configuration so callers can pass through Thousand Island options.
cond do … endinlib/prom_ex.exto a single Bandit-onlyserver_spec/5. Drops the Plug.Cowboy branch and thecowboy_opts/pool_sizeconfig keys.:banditand:plugto required deps; drops:plug_cowboy.bandit_opts:keyword inmetrics_serverconfig that's spliced intoBandit.child_spec/1, with defensiveKeyword.dropfor:scheme/:plug/:port.test/prom_ex/config_test.exs,test/prom_ex/metrics_server/startup_test.exs).Why
fly_deploy's blue/green mode injects `reuseport: true, reuseaddr: true` into the Phoenix Endpoint's transport at peer-boot so old and new peers can both bind the same port during cutover. We want the same overlap-tolerance for the standalone metrics listener — without it, the new peer fails `:eaddrinuse` during the brief overlap.
Example downstream config (sprites-api):
```elixir
config :sprites, Sprites.PromEx,
metrics_server: [
port: 9568,
path: "/metrics",
protocol: :http,
auth_strategy: :none,
bandit_opts: [
thousand_island_options: [
transport_options: [reuseport: true, reuseaddr: true]
]
]
]
```
Test plan
🤖 Generated with Claude Code