-
Notifications
You must be signed in to change notification settings - Fork 619
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 new & improved glob matcher #457
Changes from 3 commits
48dbe18
6e2b05b
6cd642b
e13a5a8
c19bd67
6b7a0ef
1eb27b9
59d967d
9d1d82a
315cde9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import ( | |
"strconv" | ||
"strings" | ||
|
||
"github.com/gobwas/glob" | ||
"github.com/fabiolb/fabio/metrics" | ||
) | ||
|
||
|
@@ -36,6 +37,9 @@ type Route struct { | |
// total contains the total number of requests for this route. | ||
// Used by the RRPicker | ||
total uint64 | ||
|
||
// Matcher represents compiled pattern. | ||
Matcher glob.Glob | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
} | ||
|
||
func (r *Route) addTarget(service string, targetURL *url.URL, fixedWeight float64, tags []string, opts map[string]string) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import ( | |
|
||
"github.com/fabiolb/fabio/metrics" | ||
"github.com/ryanuber/go-glob" | ||
glob2 "github.com/gobwas/glob" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please name this |
||
) | ||
|
||
var errInvalidPrefix = errors.New("route: prefix must not be empty") | ||
|
@@ -153,7 +154,7 @@ func (t Table) addRoute(d *RouteDef) error { | |
switch { | ||
// add new host | ||
case t[host] == nil: | ||
r := &Route{Host: host, Path: path} | ||
r := &Route{Host: host, Path: path, Matcher: glob2.MustCompile(path)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if this is an invalid pattern? Does it |
||
r.addTarget(d.Service, targetURL, d.Weight, d.Tags, d.Opts) | ||
t[host] = Routes{r} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer if you compile the glob matcher in the test since this keeps the changeset smaller, e.g.