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

Add validation to Set(peers ...string) #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add validation to Set(peers ...string) #142

wants to merge 1 commit into from

Commits on Oct 8, 2020

  1. This commit adds validation to Set(peers ...string) to check if eac…

    …h `peers` input value is a valid base URL with scheme as required and as noted in the func-level comments.
    
    The prior version of `Set()` did not include any validation of the input value(s) even though the func-level comments noted "Each peer value should be a valid base URL, for example 'http://example.net:8000'".  This could lead to confusion when a cluster of peers cannot communicate.  For example, if a user called `Set("localhost:8080")` this may look correct but the host on which `Set()` was called will not be able to communicate with the peer provided via the address `localhost:8080`.  This is compounded by the fact no error is returned, nor is anything logged, leading the user to believe the error is elsewhere besides with the inputted address.
    
    To solve the above noted issue/confusion, `Set()` was modified to check if each input value is a valid URL and return an error when an input value is invalid.  This is done by checking if the input URL has the required scheme (http or https since groupcache only uses http based communication at this point) and if a host was provided.  Modifying the `Set()` func to return an `error` should not break anything since you can ignore return values from funcs.
    
    The lines of code within the `Set()` func were reordered so that validation of input peer address could be done before setting of any pool data.
    c9845 committed Oct 8, 2020
    Configuration menu
    Copy the full SHA
    a2a6a3a View commit details
    Browse the repository at this point in the history