Skip to content
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

Implement user_supplied_options behavior. #1234

Commits on Mar 9, 2017

  1. Separate Config method so we can test output

    The RackHandler for Puma has configuration options that I want to test without booting up a server. By separating out into a new method we can do this easily.
    schneems committed Mar 9, 2017
    Configuration menu
    Copy the full SHA
    6dde986 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c946d15 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    01b38fc View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e80b0cf View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    cda9317 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    24f1257 View commit details
    Browse the repository at this point in the history
  7. Implement user_supplied_options behavior.

    When options are passed to the Puma rack handler it is unknown if the options were set via a framework as a default or via a user. Puma currently has 3 different sources of configuration, the user via command line, the config files, and defaults. 
    
    Rails 5.1+ will record the values actually specified by the user versus the values specified by the frameworks. It passes these values to the Rack handler and now it's up to Puma to do something with that information.
    
    When only framework defaults are passed it will set
    
    ```
    options[:user_supplied_options] = []
    ```
    
    When one or more options are specified by the user such as `:Port` then those keys will be in the array. In that example it will look like this
    
    
    ```
    options[:user_supplied_options] = [:Port]
    ```
    
    This change is 100% backwards compatible. If the framework is older and does not pass this information then the `user_supplied_options` will not be set, in that case we assume all values are user supplied.
    
    Internally we accomplish this separation by replacing `LeveledOptions` which was a generic way of specifying options with different priorities with a more explicit `UserFileDefaultOptions` this assumes only 3 levels of options and it will use them in the order supplied (user config wins over file based config wins over defaults).
    
    Now instead of using 1 dsl to set all values, we use 3. A user dsl, a file dsl and a Configuration.new` will return all 3 DSLs to the block. It's up to the person using the block to use the correct dsl corresponding to the source of data they are getting.
    schneems committed Mar 9, 2017
    Configuration menu
    Copy the full SHA
    85dfe8e View commit details
    Browse the repository at this point in the history
  8. Remove un-used class method

    schneems committed Mar 9, 2017
    Configuration menu
    Copy the full SHA
    7215699 View commit details
    Browse the repository at this point in the history
  9. Formatting

    schneems committed Mar 9, 2017
    Configuration menu
    Copy the full SHA
    3dcf7dc View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    995ed8b View commit details
    Browse the repository at this point in the history
  11. Remove unused methods

    schneems committed Mar 9, 2017
    Configuration menu
    Copy the full SHA
    89f3743 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    82cdefd View commit details
    Browse the repository at this point in the history
  13. Method Docs

    schneems committed Mar 9, 2017
    Configuration menu
    Copy the full SHA
    d0c8a31 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    13d7534 View commit details
    Browse the repository at this point in the history
  15. Clean up tests

    schneems committed Mar 9, 2017
    Configuration menu
    Copy the full SHA
    852f52f View commit details
    Browse the repository at this point in the history