Skip to content

Feature: Standardize an API for Rack Handler to distinguish between user specified and default options #39

@schneems

Description

@schneems

Context

For rack servers that have tiers of configuration they need ways to accurately determine what values came from where. Puma has: cli args, a ruby based config file, env var support, and default values. There is an explicit and consistent order to how these configuration operations are applied when running with the puma command, but when running via rack handler like rails server it's unclear if a port came from rails defaults or from rails server --port 3001.

If a user has a port(1234) in their puma.rb and we also get passed a :Port from the rack handler, we needed a way to know if it was user supplied or a default from upstream. We solved this specific problem already, but we didn't ever encode the behavior in the spec so other servers either have to magically discover this API or deal with worse integration (and other frameworks like Hanami) might not even know about this interface and get a worse integration.

Proposal

I propose we standardize some interface, either accepting the current Puma/Rails solution (which seems to have worked well and hasn't needed much work), or a new solution that meets the same needs and would allow for backwards compatability so frameworks like Rails can "dual boot" our old ad-hoc solution and a new "spec compliant" solution at the same time.

History

Here's the commit where I added that behavior puma/puma@85dfe8e as a part of PR puma/puma#1234 and on the Rails side rails/rails#28137.

Current code lives at: https://github.com/puma/puma/blob/38ded9c1e8e82a130a86e1135eb07aa76b58d8fb/lib/rack/handler/puma.rb#L22-L26

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions